From e3bff6a571c1561a187e88ec5e355b189a4cdad2 Mon Sep 17 00:00:00 2001 From: Carlos Date: Sun, 14 Oct 2012 17:59:20 +0300 Subject: Update goupx.go Typing goupx shouldn't panic, instead show command help. --- goupx.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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.") -- cgit v1.2.3