https://github.com/juliandavidmr/menu-args
Toolkit for creating command line interfaces without writing so much code.
https://github.com/juliandavidmr/menu-args
args argument-parser cli nodejs
Last synced: about 1 year ago
JSON representation
Toolkit for creating command line interfaces without writing so much code.
- Host: GitHub
- URL: https://github.com/juliandavidmr/menu-args
- Owner: juliandavidmr
- License: mit
- Created: 2018-04-21T05:30:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-25T16:46:20.000Z (about 8 years ago)
- Last Synced: 2025-02-06T12:48:44.826Z (about 1 year ago)
- Topics: args, argument-parser, cli, nodejs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/menu-args
- Size: 52.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# menu-args
Toolkit for creating command line interfaces without writing so much code.
> `menu-args` uses the [args](https://github.com/leo/args) package.
```js
const menu = require('menu-args')
var args = menu(`
Commands
serve "Run server"
build
reload
Options
user "Username"
pass "Password system"
state
port (8080) "Port, default value"
`)
console.log(args.parse(process.argv))
```
If the command is executed:
```bash
node test.js -u the.user -p 1a2b3c
```
it is obtained:
```js
/* { P: '8080',
port: '8080',
u: 'the.user',
user: 'the.user',
p: '1a2b3c',
pass: '1a2b3c' } */
```
> Note that the variable [`args`](https://github.com/leo/args) is exactly the args package
## Install
```bash
npm install menu-args --save
```
### Example
If you run function `args.showHelp()`, we'll see:
```txt
Usage: test.js [options] [command]
Commands:
build, b
help Display help
reload undefined
serve "Run server"
version Display version
Options:
-h, --help Output usage information
-p, --pass Password system
-P, --port [value] Port, default value (defaults to "8080")
-s, --state
-u, --user "Username"
-v, --version Output the version number
```
License MIT