Skip to content
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

Changes to urfave CLI, implements version command and one-page doc #218

Merged
merged 5 commits into from
May 21, 2021

Conversation

codefromthecrypt
Copy link
Contributor

@codefromthecrypt codefromthecrypt commented May 14, 2021

This changes to urfave CLI, which is easier to work with than Cobra.

Pros of both:

  • long source history, large amount of stars, reasonably frequent releases
  • support the platforms we need (macOS, Windows, linux)
  • support things we need in the future like auto-completion Introduce CLI completion to getenvoy #115

Pros of urfave:

  • significantly less indirect dependencies (283 less lines in go.sum)
  • supports ENV variables without introducing another dependency
  • cleaner support for go context (haven't used it yet)
  • less awkward function names and behaviors (ex. Before instead of PersistentPreRunE)
  • simpler help output and markdown (ex single page vs multi-page)
  • slightly smaller binary (They even measure it!)

Cons of urfave

  • doesn't yet support argument metadata
    • We only have two args, the <reference> and then anything passed to envoy -- .*, so this isn't a biggie

https://github.com/urfave/cli/blob/master/docs/v2/manual.md

@@ -1,120 +1,25 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

283 lines gone from the go.sum file

github.com/stretchr/testify v1.7.0
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/urfave/cli/v2 v2.3.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the reduction of transitive dependencies, switching to urfave CLI seems like a nice win. IMO the docs for urfave CLI are well written and the native support for environment variables is a nice add.


debug.EnableAll(r)

envoyArgs := args[1:]
return r.Run(c.Context(), envoyArgs)
envoyArgs := findEnvoyArgs(args)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the clarity of this 👍

@codefromthecrypt codefromthecrypt force-pushed the urlfave branch 2 times, most recently from 7d0061c to 3535a18 Compare May 18, 2021 12:09
@codefromthecrypt
Copy link
Contributor Author

I will try to finish this tomorrow morning asia time

This changes to urlfave CLI, implements version command and makes
markdown a single doc. Urlfave is easier and implements ENV variables
natively. It also supports auto-complete and man page generation.
Finally, it has significantly less dependencies (as noticable in the
go.sum results).

Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt codefromthecrypt changed the title Changes to urlfave CLI, implements version command and one-page doc Changes to urfave CLI, implements version command and one-page doc May 19, 2021
@codefromthecrypt codefromthecrypt marked this pull request as ready for review May 19, 2021 04:38
@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented May 19, 2021

once this is merged, I will help simplify the getenvoy.io usage of "getenvoy doc" to emit the now much simpler single page.
ex this https://github.com/tetratelabs/getenvoy.io/blob/master/ci/regen#L7

This should suffice, but if we later feel we want to edit it, we can override the template like so https://github.com/google/skia-buildbot/blob/4c87209ff9378a9befc65d5f93c4040d4fdd5922/go/urfavecli/urfavecli.go#L34 eventually, we should make markdown completely driven by the website code instead of a routing through a hidden command as mentioned in #205

Adrian Cole added 2 commits May 20, 2021 20:16
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt
Copy link
Contributor Author

I have a WIP branch for the website that correctly renders now https://github.com/tetratelabs/getenvoy.io/compare/new-usage

Screen Shot 2021-05-21 at 9 28 09 AM

pkg/cmd/app_test.go Outdated Show resolved Hide resolved
codefromthecrypt and others added 2 commits May 21, 2021 10:24
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt codefromthecrypt merged commit 155122a into master May 21, 2021
@codefromthecrypt codefromthecrypt deleted the urlfave branch May 21, 2021 02:39
@codefromthecrypt
Copy link
Contributor Author

thanks for the review @llinder and @mathetake!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants