Skip to content

Commit

Permalink
Read from stdin instead of passing --cmdFile.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: David Grisham <[email protected]>
  • Loading branch information
dgrisham committed Sep 7, 2018
1 parent 93f86e4 commit 019ae29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
27 changes: 11 additions & 16 deletions commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ var RunCmd = cli.Command{
Usage: "run command on specified nodes (or all)",
ArgsUsage: "[nodes] -- <command...>",
Flags: []cli.Flag{
cli.StringFlag{
Name: "cmdFile",
Usage: "File containing list of commands to run asynchronously on nodes.",
},
cli.BoolFlag{
Name: "terminator",
Hidden: true,
},
cli.BoolFlag{
Name: "stdin",
Hidden: true,
},
},
Before: func(c *cli.Context) error {
if !c.IsSet("cmdFile") {
if present := isTerminatorPresent(c); present {
return c.Set("terminator", "true")
}
if c.NArg() == 0 {
return c.Set("stdin", "true")
}
if present := isTerminatorPresent(c); present {
return c.Set("terminator", "true")
}
return nil
},
Expand All @@ -49,14 +50,8 @@ var RunCmd = cli.Command{

var args [][]string
var terminatorPresent []bool
if c.IsSet("cmdFile") {
cmdFile, err := os.Open(c.String("cmdFile"))
if err != nil {
return err
}
defer cmdFile.Close()

scanner := bufio.NewScanner(cmdFile)
if c.IsSet("stdin") {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
tokens := strings.Fields(scanner.Text())
term := tokens[0] == "--"
Expand Down
12 changes: 6 additions & 6 deletions plugins/ipfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ all: ipfslocal ipfsdocker
deps:
gx install

ipfslocal:
# gx-go rw
ipfslocal: deps
gx-go rw
(cd local; go build -buildmode=plugin -o ../../localipfs.so)
# gx-go uw
gx-go uw
CLEAN += localipfs.so

ipfsdocker:
# gx-go rw
ipfsdocker: deps
gx-go rw
(cd docker; go build -buildmode=plugin -o ../../dockeripfs.so)
# gx-go uw
gx-go uw
CLEAN += dockeripfs.so

.PHONY: all ipfslocal ipfsdocker

0 comments on commit 019ae29

Please sign in to comment.