mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Add initial support for reading stdin from the server binary
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/rwinkhart/MUTN/src/backend"
|
"github.com/rwinkhart/MUTN/src/backend"
|
||||||
"github.com/rwinkhart/MUTN/src/cli"
|
"github.com/rwinkhart/MUTN/src/cli"
|
||||||
@@ -16,6 +17,19 @@ func main() {
|
|||||||
helpServer()
|
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] {
|
switch args[1] {
|
||||||
case "fetch":
|
case "fetch":
|
||||||
// print all information needed for syncing to stdout for interpretation by the client
|
// print all information needed for syncing to stdout for interpretation by the client
|
||||||
|
|||||||
Reference in New Issue
Block a user