|
| 1 | +import { runBranchesAll, runBranchesDefault, runBranchesUpdateDefault } from './branches.js'; |
| 2 | + |
| 3 | +/** |
| 4 | + * Register all `codeant settings <verb>` subcommands. |
| 5 | + * |
| 6 | + * Each subcommand implementation lives in its own file alongside this index |
| 7 | + * and exports a single async function named run<Command>(opts). |
| 8 | + * |
| 9 | + * To add a new subcommand: |
| 10 | + * 1. Create src/commands/settings/<name>.js exporting run<Name>(opts). |
| 11 | + * 2. Import it here. |
| 12 | + * 3. Add a settings.command(...).action(...) block below following the |
| 13 | + * existing pattern. |
| 14 | + * |
| 15 | + * @param {import('commander').Command} program |
| 16 | + * @param {{ runCmd: Function }} helpers |
| 17 | + */ |
| 18 | +export default function registerSettingsCommands(program, { runCmd }) { |
| 19 | + const settings = program |
| 20 | + .command('settings') |
| 21 | + .description('Manage CodeAnt AI settings'); |
| 22 | + |
| 23 | + // ── branches all ─────────────────────────────────────────────────────────── |
| 24 | + settings |
| 25 | + .command('branches-all') |
| 26 | + .description('List all branches for a repository') |
| 27 | + .requiredOption('--repo <repo>', 'Repository (owner/repo)') |
| 28 | + .action((opts) => runCmd(() => runBranchesAll({ repo: opts.repo }))); |
| 29 | + |
| 30 | + // ── branches default ─────────────────────────────────────────────────────── |
| 31 | + settings |
| 32 | + .command('branches-default') |
| 33 | + .description('Get the default branch for a repository') |
| 34 | + .requiredOption('--repo <repo>', 'Repository (owner/repo)') |
| 35 | + .action((opts) => runCmd(() => runBranchesDefault({ repo: opts.repo }))); |
| 36 | + |
| 37 | + // ── branches update-default ──────────────────────────────────────────────── |
| 38 | + settings |
| 39 | + .command('branches-update-default') |
| 40 | + .description('Set the default branch for a repository') |
| 41 | + .requiredOption('--repo <repo>', 'Repository (owner/repo)') |
| 42 | + .requiredOption('--branch <name>', 'Branch name to set as default') |
| 43 | + .action((opts) => runCmd(() => runBranchesUpdateDefault({ repo: opts.repo, branch: opts.branch }))); |
| 44 | +} |
0 commit comments