aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Waller <[email protected]>2012-10-14 09:30:36 -0700
committerPeter Waller <[email protected]>2012-10-14 09:30:36 -0700
commit878e5629d728b0faa2d249c08e33af6a9b38f99b (patch)
tree5d750358b9009cb9e23543f74fec9ede50ba6e40
parentVersion 1.0 (diff)
parentUpdate goupx.go (diff)
downloadgoupx-878e5629d728b0faa2d249c08e33af6a9b38f99b.tar.xz
goupx-878e5629d728b0faa2d249c08e33af6a9b38f99b.zip
Merge pull request #1 from toqueteos/master
Don't panic if no arguments are specified
-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.")