How it works...

Flagsets can be used to set up independent lists of expected arguments, usage strings, and more. The developer is required to perform validation on a number of arguments, parsing in the right subset of arguments to commands and defining usage strings. This can be error-prone and requires a lot of iteration to get completely right.

The flag package makes parsing arguments much easier and includes convenience methods to get the number of flags, arguments, and more. This recipe demonstrates basic ways to construct a complex command-line application using arguments, including a package-level configuration, required positional arguments, multi-level command usage, and how to split these things into multiple files or packages if required.