Add initial support for reading stdin from the server binary

This commit is contained in:
2024-06-04 15:09:57 -04:00
parent 182b50cd27
commit 7ab46f7402
+14
View File
@@ -1,6 +1,7 @@
package main
import (
"bufio"
"fmt"
"github.com/rwinkhart/MUTN/src/backend"
"github.com/rwinkhart/MUTN/src/cli"
@@ -16,6 +17,19 @@ func main() {
helpServer()
}
// check if stdin was provided
stdinInfo, _ := os.Stdin.Stat()
stdinPresent := stdinInfo.Mode()&os.ModeNamedPipe != 0
var stdin []string
if stdinPresent {
// read stdin, appending each line to the stdin slice
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
stdin = append(stdin, scanner.Text())
}
}
switch args[1] {
case "fetch":
// print all information needed for syncing to stdout for interpretation by the client