| 659 | } |
| 660 | |
| 661 | export function registerStoreCommand(program: Command): void { |
| 662 | const storeCommand = new StoreCommand(); |
| 663 | // One source for the locked group one-liner: the completions registry |
| 664 | // entry, which shell completion scripts also consume. |
| 665 | const storeGroupDescription = |
| 666 | COMMAND_REGISTRY.find((entry) => entry.name === 'store')?.description ?? |
| 667 | 'Create and manage stores - standalone OpenSpec repos you register on this machine'; |
| 668 | const store = program.command('store').description(storeGroupDescription); |
| 669 | |
| 670 | store |
| 671 | .command('setup [id]') |
| 672 | .description('Create and register a local store') |
| 673 | .option('--path <path>', 'Folder where the store should live (for example ~/openspec/<id>)') |
| 674 | .option('--init-git', 'Initialize a Git repository with an initial commit (default)') |
| 675 | .option('--no-init-git', 'Skip every Git action: no init, no initial commit') |
| 676 | .option('--remote <url>', 'Canonical clone source recorded in store.yaml') |
| 677 | .option('--json', 'Output as JSON') |
| 678 | .action(async (id: string | undefined, options: StoreSetupOptions) => { |
| 679 | await storeCommand.setup(id, options); |
| 680 | }); |
| 681 | |
| 682 | store |
| 683 | .command('register [path]') |
| 684 | .description('Register an existing local store') |
| 685 | .option('--id <id>', 'Store id; defaults to metadata or folder name') |
| 686 | .option('--yes', 'Confirm creating store identity metadata for a healthy OpenSpec root') |
| 687 | .option('--json', 'Output as JSON') |
| 688 | .action(async (inputPath: string | undefined, options: StoreRegisterOptions) => { |
| 689 | await storeCommand.register(inputPath, options); |
| 690 | }); |
| 691 | |
| 692 | store |
| 693 | .command('unregister <id>') |
| 694 | .description('Forget a local store registration without deleting files') |
| 695 | .option('--json', 'Output as JSON') |
| 696 | .action(async (id: string, options: StoreJsonOptions) => { |
| 697 | await storeCommand.unregister(id, options); |
| 698 | }); |
| 699 | |
| 700 | store |
| 701 | .command('remove <id>') |
| 702 | .description('Forget a local store registration and delete its local folder') |
| 703 | .option('--yes', 'Confirm local store folder deletion') |
| 704 | .option('--json', 'Output as JSON') |
| 705 | .action(async (id: string, options: StoreRemoveOptions) => { |
| 706 | await storeCommand.remove(id, options); |
| 707 | }); |
| 708 | |
| 709 | store |
| 710 | .command('list') |
| 711 | .alias('ls') |
| 712 | .description('List locally registered stores') |
| 713 | .option('--json', 'Output as JSON') |
| 714 | .action(async (options: StoreJsonOptions) => { |
| 715 | await storeCommand.list(options); |
| 716 | }); |
| 717 | |
| 718 | store |