-
Notifications
You must be signed in to change notification settings - Fork 38
Description
We've just added support for gitbackup init and gitbackup validate (currently still in #203 ) and the processing of subcommands is a bit messy without some kind of framework. Especially as the tool expands it would help to have better scaffolding for this.
Right now we manually check os.Args[1] in a switch statement which has some downsides:
- no automatic help text that lists available subcommands
- no shell completion
- flag validation/subcommand wiring is messy
It looks like the most popular options are cobra (~43k stars), urfave/cli (~24k stars), kong (~3k stars), and ff/ffcli (~1.4k stars).
-
cobra
The strong points to this one are that it has auto-generated help, shell completion, and man pages. We'd have to change the project structure a bit (adding acmd/directory) and there would be a bit of refactoring involved with processing flags. -
urfave/cli
This seems like it would be a lower migration effort since it doesn't involve a project restructure. also has shell completion. looks also like processing the flags is a 1:1 conversion (StringVar -> StringFlag) -
kong
Seems like the migration would be pretty low effort because the package isn't opinionated at all about project structure -- but it's a small project with a small community which could be riskier. Also it looks like refactoring the config file override logic (combining config file with overriding flags) is a little more involved, need to use a "kong Resolver" -
ff/ffcli
Same as kong, a small community which seems less desirable. it seems like a really low effort migration but we just won't get shell completion, or help text formatting..
Overall I would go with either cobra or urfave/cli, maybe favouring urfave/cli a little bit. Let me know your thoughts