$39 GRAYBYTE WORDPRESS FILE MANAGER $45

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/cpanel/ea-nodejs22/lib/node_modules/npm/node_modules/@pkgjs/parseargs/examples/

HOME
Current File : /opt/cpanel/ea-nodejs22/lib/node_modules/npm/node_modules/@pkgjs/parseargs/examples//negate.js
'use strict';

// This example is used in the documentation.

// How might I add my own support for --no-foo?

// 1. const { parseArgs } = require('node:util'); // from node
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
const { parseArgs } = require('..'); // in repo

const options = {
  'color': { type: 'boolean' },
  'no-color': { type: 'boolean' },
  'logfile': { type: 'string' },
  'no-logfile': { type: 'boolean' },
};
const { values, tokens } = parseArgs({ options, tokens: true });

// Reprocess the option tokens and overwrite the returned values.
tokens
  .filter((token) => token.kind === 'option')
  .forEach((token) => {
    if (token.name.startsWith('no-')) {
      // Store foo:false for --no-foo
      const positiveName = token.name.slice(3);
      values[positiveName] = false;
      delete values[token.name];
    } else {
      // Resave value so last one wins if both --foo and --no-foo.
      values[token.name] = token.value ?? true;
    }
  });

const color = values.color;
const logfile = values.logfile ?? 'default.log';

console.log({ logfile, color });

// Try the following:
//    node negate.js
//    node negate.js --no-logfile --no-color
//    negate.js --logfile=test.log --color
//    node negate.js --no-logfile --logfile=test.log --color --no-color

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Mar 2026 5.04 PM
root / root
0755
is-default-value.js
0.747 KB
17 Jan 2026 1.16 AM
root / root
0644
limit-long-syntax.js
1.046 KB
17 Jan 2026 1.16 AM
root / root
0644
negate.js
1.283 KB
17 Jan 2026 1.16 AM
root / root
0644
no-repeated-options.js
0.876 KB
17 Jan 2026 1.16 AM
root / root
0644
ordered-options.mjs
1.363 KB
17 Jan 2026 1.16 AM
root / root
0644
simple-hard-coded.js
0.527 KB
17 Jan 2026 1.16 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF