I need to have the same option with and without argument. Example,
CLIParser -d 2 abc.txt
In above case d=2
CLIParser -d abc.txt
In above case d=1
I tried using .optionalArg(true) and .numberOfArgs(1) but nothing seems to work. Is this doable?
This is working fine for me.
You need both:
If there is no arg then:
will return
null. You can change that to1as your requirement.