You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
540 B
26 lines
540 B
'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
|
|
|