1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| 'use strict';
|
| // This example is used in the documentation.
|
| // 1. const { parseArgs } = require('node:util'); // from node
| // 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
| const { parseArgs } = require('..'); // in repo
|
| const args = ['-f', '--bar', 'b'];
| const options = {
| foo: {
| type: 'boolean',
| short: 'f'
| },
| bar: {
| type: 'string'
| }
| };
| const {
| values,
| positionals
| } = parseArgs({ args, options });
| console.log(values, positionals);
|
| // Try the following:
| // node simple-hard-coded.js
|
|