Skip to main content

Parser Only

This example demonstrates how to use @cli-forge/parser to interpret CLI arguments without the need for a CLI framework. For single-command CLIs, this may be enough.

Code

Parser Only
import { parser } from '@cli-forge/parser';

const argv = parser()
.option('name', {
type: 'string',
description: 'The name to say hello to',
default: 'World',
})
.parse(process.argv.slice(2));

console.log(`Hello, ${argv.name}!`);

View on TypeScript Playground

Usage

node ./parser-only.js --name sir

These examples are ran as e2e tests on pull-requests and releases to verify they are accurate and up to date. If you see any issues, please open an issue on the github repo.