aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-11-05 00:12:31 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-11-05 00:12:31 +0900
commit861bb1274febf985e205dc96c9c895d3beff3527 (patch)
tree2570f68ba255c863d4a7b69624aec924cc0f757c
parent714818c8aa1a26450cdfac0828d1a9528fdb95a4 (diff)
fortify: override default usage function
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
-rw-r--r--main.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/main.go b/main.go
index 7c0a218d..b8bb0916 100644
--- a/main.go
+++ b/main.go
@@ -35,16 +35,7 @@ func main() {
// not fatal: this program runs as the privileged user
}
- flag.Parse()
- fmsg.SetVerbose(flagVerbose)
-
- // root check
- if os.Geteuid() == 0 {
- fmsg.Fatal("this program must not run as root")
- panic("unreachable")
- }
-
- printHelp := func() {
+ flag.CommandLine.Usage = func() {
fmt.Println()
fmt.Println("Usage:\tfortify [-v] COMMAND [OPTIONS]")
fmt.Println()
@@ -67,10 +58,18 @@ func main() {
}
fmt.Println()
}
+ flag.Parse()
+ fmsg.SetVerbose(flagVerbose)
+
+ // root check
+ if os.Geteuid() == 0 {
+ fmsg.Fatal("this program must not run as root")
+ panic("unreachable")
+ }
args := flag.Args()
if len(args) == 0 {
- printHelp()
+ flag.CommandLine.Usage()
fmsg.Exit(0)
}
@@ -94,7 +93,7 @@ func main() {
}
fmsg.Exit(0)
case "help": // print help message
- printHelp()
+ flag.CommandLine.Usage()
fmsg.Exit(0)
case "ps": // print all state info
var w *tabwriter.Writer