スキル一覧に戻る
mcclowes

commander

by mcclowes

OAS Markdown Grammar is a human-first domain-specific language for API specification

1🍴 0📅 2026年1月12日
GitHubで見るManusで実行

SKILL.md


name: commander

prettier-ignore

description: Use when building CLI tools with Commander.js - commands, options, arguments, and help text for Node.js command-line applications

Commander.js CLI Framework

Quick Start

import { Command } from 'commander';

const program = new Command();

program
  .name('mycli')
  .version('1.0.0')
  .description('My CLI tool');

program
  .command('build <input>')
  .description('Build the project')
  .option('-o, --output <file>', 'Output file', 'output.json')
  .option('-w, --watch', 'Watch mode')
  .option('-v, --verbose', 'Verbose output')
  .action((input, options) => {
    console.log(`Building ${input} to ${options.output}`);
    if (options.watch) startWatcher();
  });

program.parse();

Command Patterns

PatternSyntaxDescription
Required arg<name>Must be provided
Optional arg[name]Can be omitted
Variadic<files...>Multiple values
Option value-o, --out <file>Option with value
Boolean flag-v, --verboseTrue when present
Negatable--no-cacheSets cache=false

Subcommands

const build = program.command('build');

build
  .command('dev')
  .description('Development build')
  .action(() => { /* ... */ });

build
  .command('prod')
  .description('Production build')
  .action(() => { /* ... */ });

Key Features

// Default values
.option('-p, --port <number>', 'Port', '3000')

// Coercion
.option('-n, --number <n>', 'A number', parseInt)

// Required options
.requiredOption('-c, --config <path>', 'Config file')

// Choices
.option('-e, --env <env>', 'Environment').choices(['dev', 'prod'])

// Error handling
program.exitOverride(); // Throw instead of process.exit
program.configureOutput({ writeErr: (str) => logger.error(str) });

Tips

  • Use program.parse() at the end, or program.parseAsync() for async
  • Access args via action callback or program.args
  • Use .alias('b') for command shortcuts
  • Add examples with .addHelpText('after', 'Examples:\n $ mycli build src/')

スコア

総合スコア

65/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

レビュー

💬

レビュー機能は近日公開予定です