Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-cmds
Commits
49cf8cee
Unverified
Commit
49cf8cee
authored
Mar 21, 2019
by
Steven Allen
Committed by
GitHub
Mar 21, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #157 from ipfs/feat/stdin-name
Handle stdin name in cli/parse
parents
4ca651ae
a55e1114
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
cli/parse.go
cli/parse.go
+8
-3
opts.go
opts.go
+5
-0
No files found.
cli/parse.go
View file @
49cf8cee
...
...
@@ -70,7 +70,7 @@ func Parse(ctx context.Context, input []string, stdin *os.File, root *cmds.Comma
}
func
isHidden
(
req
*
cmds
.
Request
)
bool
{
h
,
ok
:=
req
.
Options
[
"h
idden
"
]
.
(
bool
)
h
,
ok
:=
req
.
Options
[
cmds
.
H
idden
]
.
(
bool
)
return
h
&&
ok
}
...
...
@@ -79,6 +79,11 @@ func isRecursive(req *cmds.Request) bool {
return
rec
&&
ok
}
func
stdinName
(
req
*
cmds
.
Request
)
string
{
name
,
_
:=
req
.
Options
[
cmds
.
StdinName
]
.
(
string
)
return
name
}
type
parseState
struct
{
cmdline
[]
string
i
int
...
...
@@ -265,7 +270,7 @@ func parseArgs(req *cmds.Request, root *cmds.Command, stdin *os.File) error {
return
err
}
fpath
=
""
fpath
=
stdinName
(
req
)
file
,
err
=
files
.
NewReaderPathFile
(
stdin
.
Name
(),
r
,
nil
)
if
err
!=
nil
{
return
err
...
...
@@ -308,7 +313,7 @@ func parseArgs(req *cmds.Request, root *cmds.Command, stdin *os.File) error {
return
err
}
fileArgs
[
""
],
err
=
files
.
NewReaderPathFile
(
stdin
.
Name
(),
r
,
nil
)
fileArgs
[
stdinName
(
req
)
],
err
=
files
.
NewReaderPathFile
(
stdin
.
Name
(),
r
,
nil
)
if
err
!=
nil
{
return
err
}
...
...
opts.go
View file @
49cf8cee
...
...
@@ -15,6 +15,9 @@ const (
OptShortHelp
=
"h"
OptLongHelp
=
"help"
DerefLong
=
"dereference-args"
StdinName
=
"stdin-name"
Hidden
=
"hidden"
HiddenShort
=
"H"
)
// options that are used by this package
...
...
@@ -23,3 +26,5 @@ var OptionRecursivePath = cmdkit.BoolOption(RecLong, RecShort, "Add directory pa
var
OptionStreamChannels
=
cmdkit
.
BoolOption
(
ChanOpt
,
"Stream channel output"
)
var
OptionTimeout
=
cmdkit
.
StringOption
(
TimeoutOpt
,
"Set a global timeout on the command"
)
var
OptionDerefArgs
=
cmdkit
.
BoolOption
(
DerefLong
,
"Symlinks supplied in arguments are dereferenced"
)
var
OptionStdinName
=
cmdkit
.
StringOption
(
StdinName
,
"Assign a name if the file source is stdin."
)
var
OptionHidden
=
cmdkit
.
BoolOption
(
Hidden
,
HiddenShort
,
"Include files that are hidden. Only takes effect on recursive add."
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment