Deduplicate usage error message
@@ -124,13 +124,6 @@ func Check(e error) {
}
func Start(args []string) string {
-
- // Need at least one argument for C file path
- if len(args) < 2 {
- fmt.Fprintf(os.Stderr, "Usage: %s tests/misc/prime.c > /tmp/prime.go\n", args[0])
- os.Exit(1)
- }
-
if os.Getenv("GOPATH") == "" {
panic("The $GOPATH must be set.")
}
@@ -186,13 +179,14 @@ func Start(args []string) string {
func main() {
flag.Usage = func() {
- fmt.Fprintln(os.Stderr, "Usage: c2go <file.c>")
+ fmt.Fprintln(os.Stderr, "Usage: %s <file.c>", os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
if flag.NArg() < 1 {
flag.Usage()
+ os.Exit(1)
}
fmt.Print(Start(flag.Args()))
}
