We break down a basic (but working) CLI contract in Go: where the command “verb” is (
add/
list/
done), what to do with positional arguments (via
flag.Args(),
flag.NArg(),
flag.Arg(i)), and what to do with flags (
-priority,
-limit). Plus: why the standard
flag.Parse() “doesn’t like” flags after the command, how to build a dispatcher with
switch, how to validate input (including
err
!=
nil), and why you should remember the terminator
--.