I would like to create command-line tool like git
, go
or aws
in which we will pass some sub-commands to the main command and the last sub-command could also have some flags. Some examples are:
git add <file>
go build <file>
aws s3 cp --recursive <src> <dest>
Here are some examples of my hypothetical tool:
mytool cmd1
mytool cmd2 -f <path>
mytool cmd3 -f1 -f2 value --flag3 <path>
I know we can use the fmt
package for defining and parsing flags, but I don't know if this package gives me the feature I described above or not. I was wondering if there is any built-in package for doing so?