diff options
| author | Peter Waller <[email protected]> | 2012-10-14 09:30:36 -0700 |
|---|---|---|
| committer | Peter Waller <[email protected]> | 2012-10-14 09:30:36 -0700 |
| commit | 878e5629d728b0faa2d249c08e33af6a9b38f99b (patch) | |
| tree | 5d750358b9009cb9e23543f74fec9ede50ba6e40 | |
| parent | Version 1.0 (diff) | |
| parent | Update goupx.go (diff) | |
| download | goupx-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.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.") |