mitchellh / cli

A Go library for implementing command-line interfaces.
Mozilla Public License 2.0
1.73k stars 123 forks source link

Versus cobra cli #83

Closed 030 closed 4 years ago

030 commented 4 years ago

Could you explain the differences with cobra cli. What are pros to choose this CLI over the cobra and flags?

https://github.com/spf13/cobra https://gobyexample.com/command-line-flags

I am using your homdir library as well and it is very handy. I will try this library as well and perhaps it would be interesting to add a paragraph regarding the differences. I will report my findings and I could submit a PR and I am also curious what is your point of view regarding the differences.

mitchellh commented 4 years ago

Yeah that's probably a good idea. I'm honestly not super sure anymore.

This library predates Cobra, so that wasn't an option when I started. Cobra went the route of much more framework-y with a lot of features included. I believe Cobra provides many more features over this library. However, this library provides you very few features and lets you plug in alternate libraries for additional functionality, something I view as a positive. For example, you can use any flag library you want, you can generate help with it, etc. Additionally, we use this library at HashiCorp in all our tools so there will always be some level of maintenance here.

I think if we were to start today we might use Cobra instead of building our own CLI lib. However, now that we've already standardized on this lib and use it extensively we probably wouldn't.