Skip to content
Myr

args.literal.test.js

This file

Path

tests/args.literal.test.js

34 lines · 1.4 KiB · JavaScript

Last changed by

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

History of this file

Take it

The walk stopped after 200 commits: lines older than 471ec40 point at it.

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

lines 1–3why, one step back
1import * as commander from '../index.js';
2import { test, describe } from 'node:test';3import assert from 'node:assert/strict';

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 4–9why, one step back
4
5// Utility Conventions: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_026//7// 12.2 Utility Syntax Guidelines, Guideline 10:8// The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.9

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 10–23why, one step back
10describe('end of options delimiter "--"', () => {
11 test('when arguments includes -- then stop processing options', () => {12 const program = new commander.Command();13 program14 .option('-f, --foo', 'add some foo')15 .option('-b, --bar', 'add some bar')16 .argument('[args...]');17 program.parse(['node', 'test', '--foo', '--', '--bar', 'baz']);18 // More than one assert, ported from legacy test19 const opts = program.opts();20 assert.equal(opts.foo, true);21 assert.equal(opts.bar, undefined);22 assert.deepEqual(program.args, ['--bar', 'baz']);23 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 24why, one step back
24

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 25–33why, one step back
25 test('when arguments include -- then more -- are passed-through as args', () => {
26 const program = new commander.Command();27 program28 .option('-f, --foo', 'add some foo')29 .option('-b, --bar', 'add some bar')30 .argument('[args...]');31 program.parse(['node', 'test', '--', 'cmd', '--', '--arg']);32 assert.deepEqual(program.args, ['cmd', '--', '--arg']);33 });

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

line 34why, one step back
34});