1234567891011121314151617181920212223242526272829303132333435 |
- 'use strict';
- const { parseArgs } = require('..');
- const options = {
- file: { short: 'f', type: 'string' },
- log: { type: 'string' },
- };
- const { values, tokens } = parseArgs({ options, tokens: true });
- const badToken = tokens.find((token) => token.kind === 'option' &&
- token.value != null &&
- token.rawName.startsWith('--') &&
- !token.inlineValue
- );
- if (badToken) {
- throw new Error(`Option value for '${badToken.rawName}' must be inline, like '${badToken.rawName}=VALUE'`);
- }
- console.log(values);
|