cmds: fixed help stdio use
Juan Batiz-Benet committed
Nov 15, 2014 at 09:04 UTC
3df1513ea6c4200848ba645e0ef2635eefde79fd
1 file changed
+6
-6
cmd/ipfs2/main.go
+6
-6
@@ -59,13 +59,13 @@ func main() {
59
60
// this is a local helper to print out help text.
61
// there's some considerations that this makes easier.
62
- printHelp := func(long bool) {
62
+ printHelp := func(long bool, w io.Writer) {
63
helpFunc := cmdsCli.ShortHelp
64
if long {
65
helpFunc = cmdsCli.LongHelp
66
}
67
68
- helpFunc("ipfs", Root, invoc.path, os.Stderr)
68
+ helpFunc("ipfs", Root, invoc.path, w)
69
}
70
71
// parse the commandline into a command invocation
@@ -80,7 +80,7 @@ func main() {
80
os.Exit(1)
81
}
82
if longH || shortH {
83
- printHelp(longH)
83
+ printHelp(longH, os.Stdout)
84
os.Exit(0)
85
}
86
}
@@ -89,7 +89,7 @@ func main() {
89
// - commands with no Run func are invoked directly.
90
// - the main command is invoked.
91
if invoc.cmd == nil || invoc.cmd.Run == nil {
92
- printHelp(false)
92
+ printHelp(false, os.Stdout)
93
os.Exit(0)
94
}
95
@@ -102,7 +102,7 @@ func main() {
102
if invoc.cmd != nil {
103
// we need a newline space.
104
fmt.Fprintf(os.Stderr, "\n")
105
- printHelp(false)
105
+ printHelp(false, os.Stderr)
106
}
107
os.Exit(1)
108
}
@@ -114,7 +114,7 @@ func main() {
114
115
// if this error was a client error, print short help too.
116
if isClientError(err) {
117
- printHelp(false)
117
+ printHelp(false, os.Stderr)
118
}
119
os.Exit(1)
120
}