args-parser
args-parser copied to clipboard
Improvement: Does not work for '-m message'
Today i was searching for argument parser and I got args-parser and i also have same thinking like why it not working like
-m message
. have you any status like any one working on it or not. If not then i am interested in it to build this. In current scenario syntax is must -m=message
. it will also not work in -m = message
. so it is better if we can make as -m message
.
Standard way for arg is -m<space><message>
.
node script.js -m message
let me know if i can work on it. waiting for your response.
@eveningkid @bitdeli-chef @ZitRos @NiclasThobaben what you think about this?
Fine for me (I agree that's a standard way of passing arguments and maybe the library should support it). Up to a library maintainer.
You are right it is up to library maintainer and we can make good documentation for it rather then change of it. And also if we change it then user also have to know about it because it is hard to run with legacy code in this case.
Sounds like a good idea to me.
It should not break projects using the library though. So -m message
should then be the same as -m=message
.
But what about -m = message
? Should it result into { m: '=' }
( which would probably be the most trivial implementation) or { m: 'message' }
(which would have to be handled)?
So i wouldn't make it the standard way, rather an alternative.
It's up to @eveningkid though.
Hi all,
Thanks for raising this question, you really have a good point here :)
- I agree that
-m message
should be supported - Turning
-m x
into-m=x
as suggested by @NiclasThobaben seems best to avoid lib to break wherein use -
-m = x
should result tom: =
to be consistent with other CLIs
@vipulvyas if you want to work on a PR for this, I'll be happy to review it once ready
Just some piece of advice: make sure to thoroughly test this with all the use cases you can think of
Also, I'm sure that anyone here would be very competent to get us to a clean solution!
Keep us in touch, Vipul!
@NiclasThobaben @eveningkid okay so -m = message
should result to { m: 'message' }
right ?
just approve this and i will start.
As mentioned before, -m = message
should result to { m: '=' }
You can try this with git commit -m = message
and see that you'll get an error
So just going this way to keep it consistent with usual CLI behavior
> node sample.js -m = message
error: invalid syntax!!
syntax: node ./script.js careful -dangerous --tomatoes=3 --tonight --key=ek==
for more visit https://www.npmjs.com/package/args-parser
is this looks good to you ? @eveningkid
Do you mind creating a PR referencing this issue?
We can take the discussion from there, based on your implementation
PR: https://github.com/eveningkid/args-parser/pull/8