Unverified Commit 368b8062 authored by Whyrusleeping's avatar Whyrusleeping Committed by GitHub

Merge pull request #74 from djdv/fix/win/stdio

allow stdin on Windows
parents 66802ba1 29d5b1ea
...@@ -7,18 +7,25 @@ import ( ...@@ -7,18 +7,25 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime"
"sort" "sort"
"strings" "strings"
"github.com/ipfs/go-ipfs-cmdkit" "github.com/ipfs/go-ipfs-cmdkit"
"github.com/ipfs/go-ipfs-cmdkit/files" "github.com/ipfs/go-ipfs-cmdkit/files"
"github.com/ipfs/go-ipfs-cmds" "github.com/ipfs/go-ipfs-cmds"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
osh "gx/ipfs/QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93/go-os-helper"
) )
var log = logging.Logger("cmds/cli") 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). // Parse parses the input commandline string (cmd, flags, and args).
// returns the corresponding command Request object. // returns the corresponding command Request object.
...@@ -180,11 +187,6 @@ L: ...@@ -180,11 +187,6 @@ L:
} }
func parseArgs(req *cmds.Request, root *cmds.Command, stdin *os.File) error { 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 argDefs := req.Command.Arguments
// count required argument definitions // count required argument definitions
...@@ -420,9 +422,6 @@ func (st *parseState) parseLongOpt(optDefs map[string]cmdkit.Option) (string, in ...@@ -420,9 +422,6 @@ func (st *parseState) parseLongOpt(optDefs map[string]cmdkit.Option) (string, in
optval, err := parseOpt(k, v, optDefs) optval, err := parseOpt(k, v, optDefs)
return k, optval, err return k, optval, err
} }
const msgStdinInfo = "ipfs: Reading from %s; send Ctrl-d to stop."
func filesMapToSortedArr(fs map[string]files.File) []files.File { func filesMapToSortedArr(fs map[string]files.File) []files.File {
var names []string var names []string
for name, _ := range fs { for name, _ := range fs {
......
...@@ -40,6 +40,12 @@ ...@@ -40,6 +40,12 @@
"hash": "QmTVvctiHWZzSDZdyU5wdnXh7VF3kprHSyQFwVChos5qKu", "hash": "QmTVvctiHWZzSDZdyU5wdnXh7VF3kprHSyQFwVChos5qKu",
"name": "golang-levenshtein", "name": "golang-levenshtein",
"version": "1.0.0" "version": "1.0.0"
},
{
"author": "Kubuxu",
"hash": "QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93",
"name": "go-os-helper",
"version": "0.0.0"
} }
], ],
"gxVersion": "0.10.0", "gxVersion": "0.10.0",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment