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

Add NoOptDefValFunc #13

Open
cornfeedhobo opened this issue Oct 4, 2020 · 3 comments
Open

Add NoOptDefValFunc #13

cornfeedhobo opened this issue Oct 4, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@cornfeedhobo
Copy link
Owner

Does anyone else think it would be nice to have a function that sets the default value at runtime?

@cornfeedhobo cornfeedhobo added the enhancement New feature or request label Oct 4, 2020
@TerraTech
Copy link

Can you show a code example of what that would look like? TIA.

@cornfeedhobo
Copy link
Owner Author

@TerraTech I'm loosely thinking a Flag.NoOptDefValFunc is called during Parse. The signature could be similar to parseFunc, but with the addition of a returned string that will be used to set the value.

@TerraTech
Copy link

Would it be able to return an interface type where the singular return value can be cast as needed?

perhaps something like this would work:
Flag.NoOptDefValFunc (string) {}
Flag.NoOptDefValFuncExt (interface) {}

This would offer both the simple and advanced usage cases.

I'm sure if you add this functionality, people will find ways to use it effectively in their code.

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

No branches or pull requests

2 participants