cbeust / jcommander

Command line parsing framework for Java
Apache License 2.0
1.95k stars 332 forks source link

solve issue #501 #520

Closed HennyNile closed 1 month ago

HennyNile commented 3 years ago

Fixes #501 Hi! #501 mentioned can not use @-syntax in conjunction with arguments starting with literal @. I solve this proplem by changing the judge rule of @-syntax. The initail version recognizes the parameter value starting with @ as a file when expandAtSign is true whcih makes the program fail when some patameters' value just begin with @ and is not a file name. Then I add a judge rule that paramter value is not a file name when it begin with @/ . This is because filename in most OS can not begin with /, then the parameter value begin with @/ must not be a filename. This change bring some benefits but also add some complexity. If you want a parameter value begins with @ and not a file name like @password, you should transfer @/@password into.

mkarg commented 2 years ago

Thank you for looking into this. Indeed I do not like the idea of having a slash after @. Maybe we can find a solution that works without?

mkarg commented 4 months ago

@HennyNile Your PR is in conflict with the target branch. Can you please resolve the conflict and answer the open question? Thanks.

mkarg commented 2 months ago

@HennyNile Kindly requesting your response!

HennyNile commented 2 months ago

I am very sorry for ignoring the previous messages. I will take to solve this conflict and find some better solution in the coming week.

mkarg commented 2 months ago

No need to be sorry! :-)

mkarg commented 1 month ago

@HennyNile Any news? :-)

HennyNile commented 1 month ago

Hi, I am currently working on something important and will be available after July. If it's okay, I will address this issue at that time.

HennyNile commented 1 month ago

@mkarg Hi, I’m currently working on this issue and will discuss it with you once I’ve found a suitable solution.

mkarg commented 1 month ago

@mkarg Hi, I’m currently working on this issue and will discuss it with you once I’ve found a suitable solution.

Sounds great! :-)

HennyNile commented 1 month ago

@mkarg In retrospect of this problem, I found another way to solve it and don't change the initial usage of @ syntax.

While jcommander expands the @ syntax before it tries to parse the parameter values, it's hard to distinguish whether a string starting with @ is an @ syntax usage or a normal parameter value. Thus, I change to expand @ syntax during the parsing stage. If we meet a string starting with @ before we meet a parameter key, it is @ syntax usage. Otherwise, it is a normal parameter value.

Hope this solution helps.

mkarg commented 1 month ago

@HennyNile Thank you very much for your contribution! 👍 😄

HennyNile commented 1 month ago

Happy to help!