expandDynamicArg expands nonDynamicArgs
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start in src/main/java/com/beust/jcommander/JCommander.java around the expandDynamicArgs logic at the linked line. Reproduce the case with -abc as a parameter and -ab as a dynamic parameter, then inspect how the assignment string is handled. Done means -abc is not incorrectly split into -ab and c, while valid dynamic arguments still expand correctly.
Written by the indexing model from the issue text.
Description
If you have a parameter called -abc and a dynamic parameter -ab.
-abc will be expanded to "-ab" "c"
And behold you'll get an exception since "c" is not a valid argument for dynamic parameter.
Checking if arg should be expanded/split
https://github.com/cbeust/jcommander/blob/9f251415677106b683e4bbaf82123f0e5930cdce/src/main/java/com/beust/jcommander/JCommander.java#L472
"-abc".startsWith("-ab") && !"-abc".equals("-ab")
adding a validation that the assigment string exist in the arg should solve the problem.
if (arg.startsWith(name) && !arg.equals(name) && arg.contains(pd.getParameter().getAssignment()) {
But should probably be extracted to a method either in JCommander or a public boolean handlesArg(arg) in WrappedParameter which could handle the name validation and remove some of the nesting in expandDynamicArgs.
- Dominant language
- Java
- Stars
- 2k
- Forks
- 342
- Avg merge
- 4h 10m
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cbeust/jcommander
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
cbeust/jcommander#606 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
cbeust/jcommander#605 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
cbeust/jcommander#582 · 2 comments ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 42/100
cbeust/jcommander#575 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
cbeust/jcommander#570 · 4 comments ·
All issues in cbeust/jcommander
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100