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
Programmatically "fixing" parameters after parsing #55
Comments
@martinpaljak Thanks for your interest -- sorry for my late reply. Can you give a more concrete example of the functionality you're seeking? |
I want some easy and public interface to set arguments after parsing. If one argument (arg2) implies the presence of some other argument (arg1, in my simple code), I don't have to fail ("need arg1 too!"), use intermediate variables (boolean arg1_or_equivalent_present) or OR up arguments in decision points (arg1 || arg2) but just simply "fix" the user interaction by something like "args.setArg(arg1, true)" and use "if (args.has(arg1))" throughout the code. AFAICS there is no public interface for this. |
The exact use case is reading a parameter that has a default present in input file but could also be given from command line. |
@martinpaljak Thanks for clarifying. Let me think on this one for a while. |
FYI: I wanted something like this for a pet project I'm working on. |
@TjlHope Neat, thanks! I'll certainly consider this. |
I'll try to give it a look. I usually have two passes over the command line arguments in my code: first validate the arguments, make any DWIM adjustments, then on the second pass work on the "tasks" the utility can do, executing them with the right parameters. Not sure if the "default" approach would be sufficient, but worth exploring. From my perspective it would be super easy to just call something like "args.setValue(X, Y)". |
Closing after no activity for a long time. |
Maybe it is obvious (or a dumb idea) but going through the examples and docs I did not find a way to "fix up" parameters.
If a parameter -X (input source) is given, some other parameters -Y and -Z can be set to a default value read from that source and the rest of the code could work just the way it is, making decisions based on the presence and values of Y and Z. So I'd like to write something along the lines of
The text was updated successfully, but these errors were encountered: