Non-Strict Mode (Default)

This example demonstrates the default behavior without strict mode. Unmatched arguments are collected in the unmatched array and don't cause errors.

All Example Files

FILE EXPLORER
non-strict-mode.ts
1import cliForge from 'cli-forge';
2
3const cli = cliForge('non-strict-mode-example')
4  // Strict mode is disabled by default
5  .strict(false)
6  .option('name', {
7    type: 'string',
8    description: 'The name to greet',
9    default: 'World',
10  })
11  .command('$0', {
12    builder: (args) => args,
13    handler: (args) => {
14      console.log(`Hello, ${args.name}!`);
15      console.log('Unmatched:', args.unmatched);
16    },
17  });
18
19export default cli;
20
21if (require.main === module) {
22  (async () => {
23    await cli.forge();
24  })();
25}
26