|
751 | 751 | }
|
752 | 752 | })
|
753 | 753 |
|
| 754 | +// Activate command - user-friendly alias for dev:on |
| 755 | +cli |
| 756 | + .command('activate [dir]', 'Activate development environment for current or specified directory') |
| 757 | + .alias('on') |
| 758 | + .alias('enable') |
| 759 | + .option('--silent', 'Suppress output messages') |
| 760 | + .option('--shell-safe', 'Output shell-safe message without ANSI escape sequences') |
| 761 | + .example('launchpad activate') |
| 762 | + .example('launchpad on /path/to/project') |
| 763 | + .example('launchpad enable') |
| 764 | + .action(async (dir?: string, options?: { silent?: boolean, shellSafe?: boolean }) => { |
| 765 | + try { |
| 766 | + const targetDir = dir ? path.resolve(dir) : process.cwd() |
| 767 | + |
| 768 | + // Show activation message if not explicitly silenced |
| 769 | + if (!options?.silent) { |
| 770 | + // Show activation message if configured |
| 771 | + if (config.showShellMessages && config.shellActivationMessage) { |
| 772 | + let message = config.shellActivationMessage.replace('{path}', path.basename(targetDir)) |
| 773 | + |
| 774 | + // If called with shell-safe option, strip ANSI escape sequences to prevent shell parsing issues |
| 775 | + if (options?.shellSafe) { |
| 776 | + // eslint-disable-next-line no-control-regex |
| 777 | + message = message.replace(/\u001B\[[0-9;]*m/g, '') |
| 778 | + } |
| 779 | + |
| 780 | + console.log(message) |
| 781 | + } |
| 782 | + } |
| 783 | + } |
| 784 | + catch (error) { |
| 785 | + if (!options?.silent) { |
| 786 | + console.error('Failed to activate dev environment:', error instanceof Error ? error.message : String(error)) |
| 787 | + } |
| 788 | + process.exit(1) |
| 789 | + } |
| 790 | + }) |
| 791 | + |
| 792 | +// Deactivate command - user-friendly alias for dev:off |
| 793 | +cli |
| 794 | + .command('deactivate', 'Deactivate current development environment and use system/homebrew dependencies') |
| 795 | + .alias('off') |
| 796 | + .alias('disable') |
| 797 | + .option('--silent', 'Suppress output messages') |
| 798 | + .example('launchpad deactivate') |
| 799 | + .example('launchpad off') |
| 800 | + .example('launchpad disable') |
| 801 | + .action(async (options?: { silent?: boolean }) => { |
| 802 | + try { |
| 803 | + // The actual deactivation is handled by shell functions |
| 804 | + // This command exists for consistency and user-friendly access |
| 805 | + |
| 806 | + if (!options?.silent) { |
| 807 | + // Show deactivation message if configured |
| 808 | + if (config.showShellMessages && config.shellDeactivationMessage) { |
| 809 | + console.log(config.shellDeactivationMessage) |
| 810 | + } |
| 811 | + } |
| 812 | + } |
| 813 | + catch (error) { |
| 814 | + if (!options?.silent) { |
| 815 | + console.error('Failed to deactivate dev environment:', error instanceof Error ? error.message : String(error)) |
| 816 | + } |
| 817 | + process.exit(1) |
| 818 | + } |
| 819 | + }) |
| 820 | + |
754 | 821 | // Environment management commands
|
755 | 822 |
|
756 | 823 | // List environments command
|
|
0 commit comments