Use an arg parsing library for main and subcommands
Closed this issue · 2 comments
mattlqx commented
There's a ton of community packages out there for handling cli arguments. There's presently the following issues in handling args in vsh:
- subcommands only recognize flags at the end of a command
- flags can't be combined in current implementation (-abc)
- main arg splitting is custom implementation
- args that accept values aren't implemented
- help strings are created by hand as opposed to coming from structure
For all these reasons, a good community library should be leveraged. https://github.com/avelino/awesome-go#command-line has a dizzying list of what's available.
mattlqx commented
I personally think https://github.com/alexflint/go-arg is the way to go here. Args are defined in a struct and supports subcommands which gels nicely with how they're implemented today.
fishi0x01 commented
Good point - thank you! 👍
The amount of flags has been growing quite a bit. So an arg-parse library definitely makes sense.
I see you also already implemented this. Will have a look at your PR today.