-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Question: is it possible to make CLI replace parameter dashes with underscores? #301
Comments
Currently no. But could be added. |
@mauvilsa I don't mind digging into the code if you have a hunch about the most harmonious direction to try. Should I add it as a specific option to |
@iskandr certainly, please dig into the code. Contributions are welcome! Though, note that this feature is not as simple as it sounds. New features only make sense if they play well and are consistent with all other existing features. It is not just modifying There are questions to answer:
One important question is: what is the motivation for this feature and does it justify the effort to implement and maintain? I have thought about this feature several times, and the motivation mostly is preference and be slightly easier to type in most keyboards. On the other hand, a drawback of dashes is that the command line options are no longer exactly the same as the corresponding parameters in the source code. Not a very strong motivation, which is why I haven't implemented. @iskandr why exactly do you need it? What does it imply if you don't have it? I have been refactoring and cleaning up the code to make it easier for people to contribute. Unfortunately, it is still not easy. |
Thanks for your reply @mauvilsa. I can start with the motivation and circle back on implementation details once I get more familiar with this repo. I would want hyphens/dashes (instead of underscores) to maintain consistency with other tools I have developed over the past decade. It would be very confusing to have to switch between dashes and underscores depending on the tool. More generally, dashes are the GNU standard (https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html) and (somewhat subjectively) seem to be preferred by many other library/tool maintainers (eg pytorch/pytorch#65052, rspec/rspec-core#497). |
How about: If |
Some thoughts:
In the previous points when I say that something is not possible or be a certain way, does not mean that it is the only possibility. What I mean is that doing it differently will very likely complicate the code significantly. As I mentioned before, the code is already complex enough and I am trying to simplify things. Thus, please consider this as very important. Is it for you reasonable the compromise that always the arguments have both options? One possible improvement that could be done on top of this, is that for tab completion ( I think it is now more clear to me how all of this could be implemented. Would you like me to describe it? |
I'm going to close the issue for now and try out defopt to see if it covers all of my relevant use-cases. It's a smaller library, so I might circle back here if I need the full functionality of jsonargparse and try to implement @mauvilsa's vision for making CLI-only hypen aliases. (and yes, I think allowing both |
May revisit in the future! |
I will keep this open since other people might be interested. |
Hi, I'm again emphasizing the need to support the conventional (I think) multi-word dash named args. IMO an alias on named-args in the CLI is enough (the default, the help, yaml should all be Thanks, |
Hi, I'd like to see this feature as well. |
I'm curious about replacing argparse with jsonargparse in some of my projects since simply running
CLI(main_fn)
would cover my most common use cases. However, it's not clear to me if there's any hook to change the mapping from Python argument names to CLI parameters. Specifically, I typically have multi-word parameters represented with dashes as commandline arguments. So,arg_like_this
in Python comes--arg-like-this
on the commandline. Is there any way to replicate this behavior with jsonargparse?Thanks!
The text was updated successfully, but these errors were encountered: