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

hidden arguments? #64

Open
LeventErkok opened this issue Mar 2, 2020 · 6 comments
Open

hidden arguments? #64

LeventErkok opened this issue Mar 2, 2020 · 6 comments

Comments

@LeventErkok
Copy link

Is there a way to add an argument, but not make it show up in the help message? (Useful in implementing backdoor developer-only testing features.)

@ndmitchell
Copy link
Owner

@LeventErkok
Copy link
Author

Thanks Neil!

Unfortunately that's not quite what I want. I still want this to be a valid parameter to the program, just not displayed in the "help" output.

I've found this stack-overflow question that describes the issue https://stackoverflow.com/questions/33199324/hidden-arguments-with-cmdargs

But the accepted solution seems quite hackish and it dates back to 2015. So, I'm wondering if there's a better way to do the same.

@ndmitchell
Copy link
Owner

Unfortunately nothing better available I'm afraid. I can't think of a better way than that.

@LeventErkok
Copy link
Author

Thanks! I'll close this ticket; but feel free to re-open it if you want to implement something! It's definitely a nice-to-have. Much appreciated.

@ndmitchell
Copy link
Owner

Let's leave open to add - it's pretty hacky as it stands now...

@ndmitchell ndmitchell reopened this Mar 2, 2020
@LeventErkok
Copy link
Author

In case this helps anyone else, I found a workaround that sort of works. You first do:

allNames :: [String]
allNames = concatMap flagNames $ modeFlags defaultOptions

where defaultOptions is the record you construct for arguments. This grabs all the flag names. Then, do a preprocessing step and check all "flag-like" arguments to be in this list before calling cmdArgs itself. If you find anything outside, you can do a more detailed analysis as needed.

Rather hackish, but it does do the trick for my use case. I'd like to hear if anyone has a better idea that doesn't require mocking with cmdArgs itself.

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

No branches or pull requests

2 participants