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
Commits
c76a52e4
Commit
c76a52e4
authored
Nov 11, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/ipfs2: Show short help text instead for usage errors
parent
93c69a83
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
cmd/ipfs2/main.go
cmd/ipfs2/main.go
+10
-4
No files found.
cmd/ipfs2/main.go
View file @
c76a52e4
...
...
@@ -92,11 +92,12 @@ func createRequest(args []string) (cmds.Request, *cmds.Command, error) {
// handle parse error (which means the commandline input was wrong,
// e.g. incorrect number of args, or nonexistent subcommand)
if
err
!=
nil
{
help
,
_
:=
req
.
Option
(
"help"
)
.
Bool
()
// if the -help flag wasn't specified, show the error message
// or if a path was returned (user specified a valid subcommand), show the error message
// (this means there was an option or argument error)
if
path
!=
nil
&&
len
(
path
)
>
0
{
help
,
_
:=
req
.
Option
(
"help"
)
.
Bool
()
if
!
help
{
fmt
.
Printf
(
errorFormat
,
err
)
}
...
...
@@ -106,8 +107,13 @@ func createRequest(args []string) (cmds.Request, *cmds.Command, error) {
root
=
commands
.
Root
}
// generate the help text for the command the user was trying to call (or root)
htErr
:=
cmdsCli
.
LongHelp
(
"ipfs"
,
root
,
path
,
os
.
Stdout
)
// show the long help text if the help flag was specified, otherwise short help text
helpFunc
:=
cmdsCli
.
ShortHelp
if
help
{
helpFunc
=
cmdsCli
.
LongHelp
}
htErr
:=
helpFunc
(
"ipfs"
,
root
,
path
,
os
.
Stdout
)
if
htErr
!=
nil
{
fmt
.
Println
(
htErr
)
}
...
...
@@ -210,7 +216,7 @@ func outputResponse(res cmds.Response, root *cmds.Command) error {
// if this is a client error, we try to display help text
if
res
.
Error
()
.
Code
==
cmds
.
ErrClient
{
err
:=
cmdsCli
.
Long
Help
(
"ipfs"
,
root
,
res
.
Request
()
.
Path
(),
os
.
Stdout
)
err
:=
cmdsCli
.
Short
Help
(
"ipfs"
,
root
,
res
.
Request
()
.
Path
(),
os
.
Stdout
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
...
...
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