happy-coders/fun-cli

View on GitHub
src/bin/fun.ts

Summary

Maintainability
A
0 mins
Test Coverage
#!/usr/bin/env node
import commander, { CommanderStatic } from 'commander';

import { CommandLoader } from '../lib/commands/command.loader';

const bootstrap = () => {
  const program: CommanderStatic = commander;
  program
    .version(
      require('../package.json').version,
      '-v, --version',
      'Output the current version.',
    )
    .usage('<command> [options]')
    .helpOption('-h, --help', 'Output usage information.');

  CommandLoader.load(program);
  commander.parse(process.argv);

  if (!process.argv.slice(2).length) {
    program.outputHelp();
  }
};

bootstrap();