-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: standalone cli #235
feat: standalone cli #235
Conversation
Takes the required parts from `spf13/cobra` in a heavily simplified way and adds these to `pkg/cli` so that we can become independent of that massive library, which we use only a small subset from. In the future, this new package is supposed to integrate more tightly with `posener/complete`, so we have a fully integrated cli package that fits our needs: - command parsing - arbitrary flag position - native (non-script) suggestions - struct based API
Works without, no need to clutter that type
Adds native support for CLI argument and flag completion, but also validation of arguments.
Migrates from `spf13/cobra` to our very own implementation in `pkg/cli`, which is much simpler (less features, only the ones we need) and contains native support for CLI completions.
Adds a command to each app to install the CLI completions
Causes formatting changes, which we do not want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, have one nit.
I do want to say that I only validated this for correctness. I put off reviewing this for so long because introducing more internal complexity that we have to maintain ourselves makes me a little nervous. I shared these thoughts with @sh0rez and he agrees.
Overall, I don't think this is a lot of code we're adding, so I don't think it's that much of an issue, and I trust the judgment on making the call to replace Cobra with something slimmer. I personally would like to see this brought out of the repository though and made into its own project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Moves the pkg/cli package out of tree to https://github.com/go-clix/cli
Big PR implementing the parts of
spf13/cobra
we actually use ... turns out not that much after all.Motivation behind this was that
spf13/cobra
is a big library with many dependencies, that we don't use altogether. Furthermore, we want native completion usingposener/complete
, which I hacked upon cobra in an ugly way.The new package
pkg/cli
has clearly defined interfaces for all tasks we need, a simplecli.Command
struct with only the most basic features (enough for 90% of the cases) which fits exactly what Tanka needs.I expect to move this package out of Tanka in the long run, especially if we need it in other projects. For the time being it seems simplest to leave it here until it matures.
Fixes #191