Skip to content

Instantly share code, notes, and snippets.

@fernandocanizo
Created August 18, 2022 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandocanizo/66ccd84b07ada77fe329c4fbc667e8e3 to your computer and use it in GitHub Desktop.
Save fernandocanizo/66ccd84b07ada77fe329c4fbc667e8e3 to your computer and use it in GitHub Desktop.
a simple sample usage for node:util.parseArgs
#!/usr/bin/env node
// sample usage of util.parseArgs
import {parseArgs} from 'node:util';
const options = {
help: {
type: 'boolean',
short: 'h',
},
verbose: {
type: 'boolean',
short: 'v',
},
str: {
type: 'string',
short: 's',
},
int: { // non-negative integer
type: 'string',
short: 'i',
multiple: true,
},
};
const result = parseArgs({
options,
allowPositionals: true,
});
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment