Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peacefultruth/butterfly
process arguments from a data description
https://github.com/peacefultruth/butterfly
command-line command-line-arguments command-line-arguments-parser javascript npm
Last synced: 8 days ago
JSON representation
process arguments from a data description
- Host: GitHub
- URL: https://github.com/peacefultruth/butterfly
- Owner: peacefultruth
- License: mit
- Created: 2020-03-07T05:33:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T04:55:57.000Z (about 1 year ago)
- Last Synced: 2024-04-26T06:02:23.862Z (7 months ago)
- Topics: command-line, command-line-arguments, command-line-arguments-parser, javascript, npm
- Language: JavaScript
- Homepage:
- Size: 77.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# butterfly
process arguments from a data description.
just pass me the description of the process argv,
I will return you the parsed format.```bash
yarn add @peacefultruth/butterfly
```````js
import butterfly from '@peacefultruth/butterfly';
const process_arguments = (
process.argv || (
[
'node',
'entry.js','blah',
'3.14',
'-b',
'4.14',
'--blah',
'5.14','blahblah',
'100',
'-bb',
'200',
'--blahblah',
'300',
'--blah-blah',
'400',
]
)
);expect(
butterfly(
{
blah: {
aliases: ['-b', '--blah'],
is_multiple_lazy: true,
type: Number,
value: -1,
},
blahblah: {
aliases: ['-bb', '--blahblah', '--blah-blah'],
is_multiple_lazy: true,
type: Number,
value: -1,
},
},
process_arguments
)
).toEqual(
{
blah: {
aliases: ['-b', '--blah'],
is_multiple_lazy: true,
type: Number,
value: [3.14, 4.14, 5.14],
},
blahblah: {
aliases: ['-bb', '--blahblah', '--blah-blah'],
is_multiple_lazy: true,
type: Number,
value: [100, 200, 300, 400],
},
}
)````