mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-27 20:36:29 -04:00
Add initial support for reading stdin from the server binary
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user