diff options
| -rw-r--r-- | goupx.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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.") |