Skip to content

Commit

Permalink
Remove default for 'cmd' flag
Browse files Browse the repository at this point in the history
See GitHub issue #20
  • Loading branch information
ericfreese committed Oct 19, 2017
1 parent 75c7c00 commit 674cfed
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@ var flags struct {
}

func init() {
flag.StringVarP(&flags.cmd, "cmd", "c", "cat ~/.config/rat/ratrc", "command to run")
flag.StringVarP(&flags.cmd, "cmd", "c", "", "command to run (required)")
flag.StringVarP(&flags.mode, "mode", "m", "default", "name of mode")
flag.BoolVarP(&flags.version, "version", "v", false, "display version and exit")

flag.Parse()
}

func validateFlags() bool {
if len(flags.cmd) == 0 {
fmt.Fprintln(os.Stderr, "flag 'cmd' is required")
return false
}

return true
}

func main() {
var err error

Expand All @@ -35,6 +44,11 @@ func main() {
return
}

if !validateFlags() {
flag.Usage()
os.Exit(1)
}

if err = rat.Init(); err != nil {
panic(err)
}
Expand Down

0 comments on commit 674cfed

Please sign in to comment.