Comments (4)
from mri.
Hmm... so this is because mri
converts to numbers. It actually does accept zero (eg, --bar 0
), but in this particular case, it's because Number("0132568")
is 132568
from mri.
Ah, so if you know it's going to be --bar
(or --password
in this case) you should use the string
option. That's the only way to override/prevent the typecasting from happening.
mri(['--bar=0132568'], {
string: ['bar']
});
//=> { _: [], bar: '0132568' }
from mri.
Closing this since it's working as designed. Any Number
parsing will always remove preceding zeros – they can only remain when the number exists as a string.
So, in this particular case, you have to opt out of mri
's Number parsing, and that's achievable thru the snippet above.
Hope that helps, but please follow up if you need to!
Thanks~!
from mri.
Related Issues (14)
- Default value type not applied to aliases HOT 2
- Argument with with hyphen and underscore shows up as true HOT 4
- parsing of strings containing flag notation HOT 6
- arguments containing hyphens do not parse correctly HOT 2
- Open to native types?
- FR Doc: Explanation why speed is important; docs on replacing other parsers
- inconsistent parsing of numeric arguments
- Add getopts benchmark HOT 4
- with aliases, multiple values for the same flag don't work
- Number parser does not parse "0"
- Unknown handling seems wrong HOT 2
- null default arguments cause an error HOT 3
- Boolean defaults are parsed incorrectly HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mri.