aboutsummaryrefslogtreecommitdiff
path: root/weed/weed.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-03-17 23:13:25 -0700
committerchrislu <chris.lu@gmail.com>2025-03-17 23:13:27 -0700
commit7244a3d04719ecf1b52d58255424f77d87e9a43e (patch)
treecbb254fa75cba3c5e47410219280a3ec15281fd8 /weed/weed.go
parent75ef3245334f12e0b3b420ba29aeea091b7d9afa (diff)
downloadseaweedfs-7244a3d04719ecf1b52d58255424f77d87e9a43e.tar.xz
seaweedfs-7244a3d04719ecf1b52d58255424f77d87e9a43e.zip
set exit status
Diffstat (limited to 'weed/weed.go')
-rw-r--r--weed/weed.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/weed/weed.go b/weed/weed.go
index 638913ec0..cde071179 100644
--- a/weed/weed.go
+++ b/weed/weed.go
@@ -98,12 +98,15 @@ func main() {
cmd.Flag.Usage()
fmt.Fprintf(os.Stderr, "Default Parameters:\n")
cmd.Flag.PrintDefaults()
+ // Command execution failed - general error
+ setExitStatus(1)
}
exit()
return
}
}
+ // Unknown command - syntax error
fmt.Fprintf(os.Stderr, "weed: unknown subcommand %q\nRun 'weed help' for usage.\n", args[0])
setExitStatus(2)
exit()
@@ -155,19 +158,23 @@ func usage() {
printUsage(os.Stderr)
fmt.Fprintf(os.Stderr, "For Logging, use \"weed [logging_options] [command]\". The logging options are:\n")
flag.PrintDefaults()
- os.Exit(2)
+ // Invalid command line usage - syntax error
+ setExitStatus(2)
+ exit()
}
// help implements the 'help' command.
func help(args []string) {
if len(args) == 0 {
printUsage(os.Stdout)
- // not exit 2: succeeded at 'weed help'.
+ // Success - help displayed correctly
return
}
if len(args) != 1 {
fmt.Fprintf(os.Stderr, "usage: weed help command\n\nToo many arguments given.\n")
- os.Exit(2) // failed at 'weed help'
+ // Invalid help usage - syntax error
+ setExitStatus(2)
+ exit()
}
arg := args[0]
@@ -175,13 +182,15 @@ func help(args []string) {
for _, cmd := range commands {
if cmd.Name() == arg {
tmpl(os.Stdout, helpTemplate, cmd)
- // not exit 2: succeeded at 'weed help cmd'.
+ // Success - help for specific command displayed correctly
return
}
}
fmt.Fprintf(os.Stderr, "Unknown help topic %#q. Run 'weed help'.\n", arg)
- os.Exit(2) // failed at 'weed help cmd'
+ // Unknown help topic - syntax error
+ setExitStatus(2)
+ exit()
}
var atexitFuncs []func()