提交 2f2efc84 作者: Matt Bell

cmd/ipfs: On command ClientError, suggest checking helptext instead of showing…

cmd/ipfs: On command ClientError, suggest checking helptext instead of showing short helptext. Resovles #630
上级 23f810e1
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"os/signal" "os/signal"
"runtime" "runtime"
"runtime/pprof" "runtime/pprof"
"strings"
"syscall" "syscall"
"time" "time"
...@@ -78,6 +79,12 @@ func main() { ...@@ -78,6 +79,12 @@ func main() {
helpFunc("ipfs", Root, invoc.path, w) helpFunc("ipfs", Root, invoc.path, w)
} }
// this is a message to tell the user how to get the help text
printMetaHelp := func(w io.Writer) {
cmdPath := strings.Join(invoc.path, " ")
fmt.Fprintf(w, "Use 'ipfs %s --help' for information about this command\n", cmdPath)
}
// parse the commandline into a command invocation // parse the commandline into a command invocation
parseErr := invoc.Parse(ctx, os.Args[1:]) parseErr := invoc.Parse(ctx, os.Args[1:])
...@@ -112,7 +119,7 @@ func main() { ...@@ -112,7 +119,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, os.Stderr) printMetaHelp(os.Stderr)
} }
os.Exit(1) os.Exit(1)
} }
...@@ -124,7 +131,7 @@ func main() { ...@@ -124,7 +131,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, os.Stderr) printMetaHelp(os.Stderr)
} }
os.Exit(1) os.Exit(1)
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论