Skip to content

Commit

Permalink
docs: add example example with code from README/documentation (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn authored Jun 3, 2022
1 parent e43a70f commit 36060cd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/simple-hard-coded.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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

0 comments on commit 36060cd

Please sign in to comment.