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

"gomplate -in flibbit" should produce an error #192

Closed
docwhat opened this issue Aug 4, 2017 · 6 comments
Closed

"gomplate -in flibbit" should produce an error #192

docwhat opened this issue Aug 4, 2017 · 6 comments
Labels

Comments

@docwhat
Copy link

docwhat commented Aug 4, 2017

I would expect that non-flag arguments would raise an error in gomplate.

Expected:

$ gomplate -in flibbit
I don't know what to do with 'flibbit'
# non-zero exit code
$

Actual:

$ gomplate -in flibbit
n<no newline> 
# zero exit code
$

I got bit by this because I typed -in instead of --in and spent a while trying to figure out what I did wrong.

FYI: -in can be rewritten as --in 'n'

@hairyhenderson
Copy link
Owner

Thanks for reporting this, @docwhat! I agree - that's a bit odd. This used to be the case, but I think additional args are silently ignored ever since I moved to using cobra for parsing args.

@docwhat
Copy link
Author

docwhat commented Aug 6, 2017

When I was using kingpin I had a similar problem; I was not checking all the error conditions.

@docwhat
Copy link
Author

docwhat commented Aug 6, 2017

Reading the docs on arguments, I think what you want is a line in the RootCmd section saying something like:

...
Args: NoArgs,
...

But I'm not sure, since I'm just speed reading the docs and change history of cobra.

@docwhat
Copy link
Author

docwhat commented Aug 6, 2017

@hairyhenderson

P.S. For macOS users Homebrew/homebrew-core#15811

@hairyhenderson
Copy link
Owner

thanks @docwhat - I already have a tap at https://github.com/hairyhenderson/homebrew-tap, but being in core would be cool!

drmdrew added a commit to drmdrew/gomplate that referenced this issue Sep 16, 2017
@drmdrew
Copy link

drmdrew commented Sep 16, 2017

@hairyhenderson this looks to have a quick fix so I submitted PR #208 that registers cobra.NoArgs for the rootCmd as mentioned by @docwhat earlier #192 (comment)

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

No branches or pull requests

3 participants