Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 

@soundtype/commander

A type-safe wrapper around commander.js with excellent type inference.

Usage

import { program } from '@soundtype/commander';

const myProgram = program('my-app', '1.0.0')
  .option({
    name: 'bool',
    description: 'this is a boolean',
    default: false,
  })
  .option({
    name: 'num',
    description: 'this is a number',
    default: undefined,
    parse: str => {
      const value = parseInt(str, 10);
      if (Number.isNaN(value)) throw new Error('This is not an int');
      return value;
    },
  })
  .variadic({ name: 'positional', required: true })
  .build();

// result type is `{ num?: number, bool: boolean, positional: string[] }`
const result = myProgram.parse(process.argv);

Local Development

This project was bootstrapped with TSDX.

Below is a list of commands you will probably find useful.

npm start or yarn start

Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.

Your library will be rebuilt if you make edits.

npm run build or yarn build

Bundles the package to the dist folder. The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).

npm test or yarn test

Runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.

About

A type-safe wrapper around commander.js with excellent type inference.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published