diff options
| author | Carlos <[email protected]> | 2012-10-14 17:59:20 +0300 |
|---|---|---|
| committer | Carlos <[email protected]> | 2012-10-14 17:59:20 +0300 |
| commit | e3bff6a571c1561a187e88ec5e355b189a4cdad2 (patch) | |
| tree | 5d750358b9009cb9e23543f74fec9ede50ba6e40 | |
| parent | Version 1.0 (diff) | |
| download | goupx-e3bff6a571c1561a187e88ec5e355b189a4cdad2.tar.xz goupx-e3bff6a571c1561a187e88ec5e355b189a4cdad2.zip | |
Update goupx.go
Typing goupx shouldn't panic, instead show command help.
| -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.") |