Skip to content

Commit

Permalink
Merge pull request #74 from djdv/fix/win/stdio
Browse files Browse the repository at this point in the history
allow stdin on Windows
  • Loading branch information
whyrusleeping authored Apr 24, 2018
2 parents 66802ba + 29d5b1e commit 368b806
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
19 changes: 9 additions & 10 deletions cli/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"sort"
"strings"

"github.com/ipfs/go-ipfs-cmdkit"
"github.com/ipfs/go-ipfs-cmdkit/files"
"github.com/ipfs/go-ipfs-cmds"

logging "github.com/ipfs/go-log"

osh "gx/ipfs/QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93/go-os-helper"
)

var log = logging.Logger("cmds/cli")
var msgStdinInfo = "ipfs: Reading from %s; send Ctrl-d to stop."

func init() {
if osh.IsWindows() {
msgStdinInfo = "ipfs: Reading from %s; send Ctrl-z to stop."
}
}

// Parse parses the input commandline string (cmd, flags, and args).
// returns the corresponding command Request object.
Expand Down Expand Up @@ -180,11 +187,6 @@ L:
}

func parseArgs(req *cmds.Request, root *cmds.Command, stdin *os.File) error {
// ignore stdin on Windows
if runtime.GOOS == "windows" {
stdin = nil
}

argDefs := req.Command.Arguments

// count required argument definitions
Expand Down Expand Up @@ -420,9 +422,6 @@ func (st *parseState) parseLongOpt(optDefs map[string]cmdkit.Option) (string, in
optval, err := parseOpt(k, v, optDefs)
return k, optval, err
}

const msgStdinInfo = "ipfs: Reading from %s; send Ctrl-d to stop."

func filesMapToSortedArr(fs map[string]files.File) []files.File {
var names []string
for name, _ := range fs {
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
"hash": "QmTVvctiHWZzSDZdyU5wdnXh7VF3kprHSyQFwVChos5qKu",
"name": "golang-levenshtein",
"version": "1.0.0"
},
{
"author": "Kubuxu",
"hash": "QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93",
"name": "go-os-helper",
"version": "0.0.0"
}
],
"gxVersion": "0.10.0",
Expand Down

0 comments on commit 368b806

Please sign in to comment.