Skip to content

Commit ff7b426

Browse files
committed
display usage of a command when this command is wrongly used
1 parent 8930dd1 commit ff7b426

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cmd/sshproxyctl/sshproxyctl.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,15 @@ func main() {
682682
showErrorBanner(*configFile)
683683
default:
684684
fmt.Fprintf(os.Stderr, "ERROR: unknown subcommand: %s\n\n", subcmd)
685-
usage()
685+
p.Usage()
686686
}
687687
case "enable":
688688
p := parsers[cmd]
689689
p.Parse(args)
690690
host, port, err := getHostPortFromCommandLine(p.Args())
691691
if err != nil {
692692
fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err)
693-
usage()
693+
p.Usage()
694694
}
695695
enableHost(host, port, *configFile)
696696
case "forget":
@@ -699,7 +699,7 @@ func main() {
699699
host, port, err := getHostPortFromCommandLine(p.Args())
700700
if err != nil {
701701
fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err)
702-
usage()
702+
p.Usage()
703703
}
704704
forgetHost(host, port, *configFile)
705705
case "disable":
@@ -708,7 +708,7 @@ func main() {
708708
host, port, err := getHostPortFromCommandLine(p.Args())
709709
if err != nil {
710710
fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err)
711-
usage()
711+
p.Usage()
712712
}
713713
disableHost(host, port, *configFile)
714714
case "error_banner":
@@ -717,16 +717,16 @@ func main() {
717717
errorBanner, err := getErrorBannerFromCommandLine(p.Args())
718718
if err != nil {
719719
fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err)
720-
usage()
720+
p.Usage()
721721
}
722722
t, err := matchExpire(expire)
723723
if err != nil {
724724
fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err)
725-
usage()
725+
p.Usage()
726726
}
727727
if expire != "" && t.Before(time.Now()) {
728728
fmt.Fprintf(os.Stderr, "ERROR: %s is in the past!\n\n", expire)
729-
usage()
729+
p.Usage()
730730
}
731731
setErrorBanner(errorBanner, t, *configFile)
732732
default:

0 commit comments

Comments
 (0)