[READ-ONLY] Mirror of https://github.com/Schniz/soundtype-commander. A type-safe wrapper around commander.js with excellent type inference.
0

Configure Feed

Select the types of activity you want to include in your feed.

TypeScript 100.0%
9 15 0

Clone this repository

https://tangled.org/schlez.in/soundtype-commander https://tangled.org/did:plc:6obvzxrakom3mhv3f4zq4old
git@tangled.org:schlez.in/soundtype-commander git@tangled.org:did:plc:6obvzxrakom3mhv3f4zq4old

For self-hosted knots, clone URLs may differ based on your setup.



README.md

@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.