PHP 8.2.30
Preview: simple-hard-coded.js Size: 540 B
//opt/alt/alt-nodejs24/root/usr/lib/node_modules/npm/node_modules.bundled/@pkgjs/parseargs/examples/simple-hard-coded.js

'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

Directory Contents

Dirs: 0 × Files: 6

Name Size Perms Modified Actions
765 B lrw-r--r-- 2026-02-23 07:38:43
Edit Download
1.05 KB lrw-r--r-- 2026-02-23 07:38:43
Edit Download
1.28 KB lrw-r--r-- 2026-02-23 07:38:43
Edit Download
897 B lrw-r--r-- 2026-02-23 07:38:43
Edit Download
1.36 KB lrw-r--r-- 2026-02-23 07:38:43
Edit Download
540 B lrw-r--r-- 2026-02-23 07:38:43
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).