-
Notifications
You must be signed in to change notification settings - Fork 418
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
Support JCommander-style parameter files #551
Comments
Thanks for the report! I’ll look into this as soon as I can. |
I have reproduced the problem. This seems to be the behaviour of This is not great. Looking into solutions... |
About the second issue you mention, that You can switch this off with |
Sorry I meant |
Note to self: consider replacing use of |
Looking at the specification for @-files for the From the spec:
However, this documentation may be out-of-date. I will test with the |
Hmm... I tested with the I think it makes sense for picocli's @-file behaviour to be consistent with Java's @-file behaviour, what do you think? |
@remkop It makes sense to be consistent. That said, it is an incredible pain for the users who have to escape everything. Especially the beginner users of my app will be confused by this and it will have to be carefully explained. (A bit of context: I migrated my codebase from JCommander to Picocli and JCommander handled this particular situation without problems.) |
Thanks for the background. Let me check how JCommander does it. |
Looks like JCommander requires every argument to be on a separate line in the @argument-file. I can add a parser configuration to allow application authors to switch between the current spec and the JCommander behaviour. The default will be the current behaviour (both to avoid breaking existing applications and to be consistent with Java's @-file behaviour). I am thinking to add a method for this similar to The new behaviour will do the following:
What would be a good name for the configuration with this behaviour? |
@remkop When it comes to naming, I keep thinking in terms of "simplified" or "per line". Neither of those say much about what's actually going to happen, though. Perhaps we could be speaking of JCommander emulation - but that still doesn't explicitly say what it does. How about "raw mode"? No escaping means you get exactly what you write. |
Literal mode? |
These would become methods on So potential candidates so far:
|
I like either |
I like Do you feel like helping with this? The change itself is fairly straightforward (see diff below), but there's a bit of work creating the getters/setters for Will you be able to provide a PR for this?
|
@remkop I'll take a look when I can find a little time. |
Would be great! |
I am considering doing a minimal implementation for the above change that can be controlled only with a system property Not introducing new API reduces the testing and documentation effort. I also imagine that end users would like some way to control this, rather than CLI application authors. |
@remkop I am not sure there. Shouldn't the app developers be in control of how their app should behave and what kinds of inputs it will accept? In my opinion, leaving it to the user of the app opens the developer/distributor of the app to have to support something that they did not intend to. |
Generally I would agree, but in this case it is about whether the user specifies an argument file where each parameter is on a separate line, or an argument file where a line may have multiple parameters, and quotes will be stripped off. This happens transparently to the application; the application just sees the resulting arguments after picocli did the pre-processing of the argument file. It is, however, not transparent to the user. They need to know what they are doing. If they set That said, if the application needs to take control, they can: the application can just explicitly call |
Ok, in my case, I will be enforcing it through the property in my application. Anyway - if you're implementing this, do you still need anything from me? I was going to take a look at the changes you suggested towards the end of this week. |
You may still be there faster than me... Very busy with day job recently. |
@remkop OK, let's make a deal - you introduce the code, I'll add the tests. :-) |
Sounds good! :-) |
This is now implemented on master: if system property I will update the documentation. Can you provide unit tests? |
@remkop Sure, I'll take a look this weekend. Any idea for when we could have a release? |
I was thinking this weekend. |
I believe this is closed now. |
It is possible that this is a feature, but I did not find it in the documentation. See my Github repo for a complete reproducer.
Steps to reproduce
Create an argument file
argFile
such as this:Run Picocli like this:
Observe that the value of the
String
-typedOption
has been changed toC:UsersmesomeFile.txt
.Additional information
The text was updated successfully, but these errors were encountered: