aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--goupx.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/goupx.go b/goupx.go
index 05c615f..cbd5855 100644
--- a/goupx.go
+++ b/goupx.go
@@ -38,6 +38,13 @@ import (
"os/exec"
)
+const usageText = "usage: goupx [args...] path\n"
+
+// usage prints some nice output instead of panic stacktrace when an user calls goupx without arguments
+func usage() {
+ os.Stderr.WriteString(usageText)
+}
+
// The functions gethdr and writephdr are heavily influenced by code found at
// http://golang.org/src/pkg/debug/elf/file.go
@@ -167,6 +174,11 @@ func main() {
flag.Parse()
+ if flag.NArg() != 1 {
+ usage()
+ return
+ }
+
defer func() {
if err := recover(); err != nil {
log.Print("Panicked. Giving up.")