aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-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