mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-28 17:03:58 +08:00
cmds: fixed help stdio use
This commit is contained in:
@ -59,13 +59,13 @@ func main() {
|
|||||||
|
|
||||||
// this is a local helper to print out help text.
|
// this is a local helper to print out help text.
|
||||||
// there's some considerations that this makes easier.
|
// there's some considerations that this makes easier.
|
||||||
printHelp := func(long bool) {
|
printHelp := func(long bool, w io.Writer) {
|
||||||
helpFunc := cmdsCli.ShortHelp
|
helpFunc := cmdsCli.ShortHelp
|
||||||
if long {
|
if long {
|
||||||
helpFunc = cmdsCli.LongHelp
|
helpFunc = cmdsCli.LongHelp
|
||||||
}
|
}
|
||||||
|
|
||||||
helpFunc("ipfs", Root, invoc.path, os.Stderr)
|
helpFunc("ipfs", Root, invoc.path, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the commandline into a command invocation
|
// parse the commandline into a command invocation
|
||||||
@ -80,7 +80,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if longH || shortH {
|
if longH || shortH {
|
||||||
printHelp(longH)
|
printHelp(longH, os.Stdout)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ func main() {
|
|||||||
// - commands with no Run func are invoked directly.
|
// - commands with no Run func are invoked directly.
|
||||||
// - the main command is invoked.
|
// - the main command is invoked.
|
||||||
if invoc.cmd == nil || invoc.cmd.Run == nil {
|
if invoc.cmd == nil || invoc.cmd.Run == nil {
|
||||||
printHelp(false)
|
printHelp(false, os.Stdout)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ func main() {
|
|||||||
if invoc.cmd != nil {
|
if invoc.cmd != nil {
|
||||||
// we need a newline space.
|
// we need a newline space.
|
||||||
fmt.Fprintf(os.Stderr, "\n")
|
fmt.Fprintf(os.Stderr, "\n")
|
||||||
printHelp(false)
|
printHelp(false, os.Stderr)
|
||||||
}
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ func main() {
|
|||||||
|
|
||||||
// if this error was a client error, print short help too.
|
// if this error was a client error, print short help too.
|
||||||
if isClientError(err) {
|
if isClientError(err) {
|
||||||
printHelp(false)
|
printHelp(false, os.Stderr)
|
||||||
}
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user