-
Notifications
You must be signed in to change notification settings - Fork 44
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
Rewrite package terratag/cli #95
Conversation
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.
@arybolovlev great suggestion 💯
It looks like you got some tests failing there
Hi @yaronya, I've fixed this. Tests were failing due to the nature of the flag package. When you use a default I also removed the unused field Also, as you can see I've updated the Locally all tests are green now. Thank you! |
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.
Very nicely done! Thank you for your contribution!
Left one last small comment 🙏
cli/cli.go
Outdated
args.Filter = setFlag("filter", ".*") | ||
args.Verbose = booleanFlag("verbose", false) | ||
args.Rename = booleanFlag("rename", true) | ||
fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError) |
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.
Could you please extract os.Args[0]
and os.Args[1:]
into meaningful variables and use those instead?
i.e
programName := os.Args[0]
programArgs := os.Args[1:]
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.
Good catch, thank you! Updated also the test file just to have consistency.
…to improve readability
Hi there,
With this PR I would love to propose a small improvement for the terratag/cli package.
Instead of writing your own functions to manage CLI arguments, you can use the package 'flag' from the standard Golang library.
One of the benefits of using the package 'flag' is that it is coming with the build-in "help", it is done transparently by the package. Here is how it looks:
Another benefit is the build-in check for the parameters of the argument:
I am not sure if the descriptions for the options are right, please feel free to update them.
Thank you.