-
Notifications
You must be signed in to change notification settings - Fork 972
feat(cli): add plx command alias and rebrand as OpenSplx #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import '../dist/cli/index.js'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,16 @@ import { fileURLToPath } from 'url'; | |
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = path.dirname(__filename); | ||
|
|
||
| /** | ||
| * Detect the command name from the invocation path | ||
| */ | ||
| function getCommandName() { | ||
| const scriptPath = process.argv[1] || ''; | ||
| const scriptName = path.basename(scriptPath).replace(/\.js$/, ''); | ||
| // Default to 'openspec' for postinstall context | ||
| return scriptName === 'plx' ? 'plx' : 'openspec'; | ||
| } | ||
|
Comment on lines
+24
to
+29
|
||
|
|
||
| /** | ||
| * Check if we should skip installation | ||
| */ | ||
|
|
@@ -72,7 +82,7 @@ async function installCompletions(shell) { | |
|
|
||
| // Check if shell is supported | ||
| if (!CompletionFactory.isSupported(shell)) { | ||
| console.log(`\nTip: Run 'openspec completion install' for shell completions`); | ||
| console.log(`\nTip: Run 'openspec completion install' or 'plx completion install' for shell completions`); | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -99,11 +109,11 @@ async function installCompletions(shell) { | |
| } | ||
| } else { | ||
| // Installation failed, show tip for manual install | ||
| console.log(`\nTip: Run 'openspec completion install' for shell completions`); | ||
| console.log(`\nTip: Run 'openspec completion install' or 'plx completion install' for shell completions`); | ||
| } | ||
| } catch (error) { | ||
| // Fail gracefully - show tip for manual install | ||
| console.log(`\nTip: Run 'openspec completion install' for shell completions`); | ||
| console.log(`\nTip: Run 'openspec completion install' or 'plx completion install' for shell completions`); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -127,7 +137,7 @@ async function main() { | |
| // Detect shell | ||
| const shell = await detectShell(); | ||
| if (!shell) { | ||
| console.log(`\nTip: Run 'openspec completion install' for shell completions`); | ||
| console.log(`\nTip: Run 'openspec completion install' or 'plx completion install' for shell completions`); | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -136,7 +146,7 @@ async function main() { | |
| } catch (error) { | ||
| // Fail gracefully - never break npm install | ||
| // Show tip for manual install | ||
| console.log(`\nTip: Run 'openspec completion install' for shell completions`); | ||
| console.log(`\nTip: Run 'openspec completion install' or 'plx completion install' for shell completions`); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ import { COMMAND_REGISTRY } from '../core/completions/command-registry.js'; | |||||
| import { detectShell, SupportedShell } from '../utils/shell-detection.js'; | ||||||
| import { CompletionProvider } from '../core/completions/completion-provider.js'; | ||||||
| import { getArchivedChangeIds } from '../utils/item-discovery.js'; | ||||||
| import { commandName } from '../utils/command-name.js'; | ||||||
|
|
||||||
| interface GenerateOptions { | ||||||
| shell?: string; | ||||||
|
|
@@ -59,7 +60,7 @@ export class CompletionCommand { | |||||
|
|
||||||
| // No shell specified and cannot auto-detect | ||||||
| console.error('Error: Could not auto-detect shell. Please specify shell explicitly.'); | ||||||
| console.error(`Usage: openspec completion ${operationName} [shell]`); | ||||||
| console.error(`Usage: ${commandName} completion ${operationName} [shell]`); | ||||||
| console.error(`Currently supported: ${CompletionFactory.getSupportedShells().join(', ')}`); | ||||||
| process.exitCode = 1; | ||||||
| return null; | ||||||
|
|
@@ -115,7 +116,7 @@ export class CompletionCommand { | |||||
| */ | ||||||
| private async generateForShell(shell: SupportedShell): Promise<void> { | ||||||
| const generator = CompletionFactory.createGenerator(shell); | ||||||
| const script = generator.generate(COMMAND_REGISTRY); | ||||||
| const script = generator.generate(COMMAND_REGISTRY, commandName); | ||||||
| console.log(script); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -126,11 +127,11 @@ export class CompletionCommand { | |||||
| const generator = CompletionFactory.createGenerator(shell); | ||||||
| const installer = CompletionFactory.createInstaller(shell); | ||||||
|
|
||||||
| const spinner = ora(`Installing ${shell} completion script...`).start(); | ||||||
| const spinner = ora(`Installing ${shell} completion script for ${commandName}...`).start(); | ||||||
|
|
||||||
| try { | ||||||
| // Generate the completion script | ||||||
| const script = generator.generate(COMMAND_REGISTRY); | ||||||
| const script = generator.generate(COMMAND_REGISTRY, commandName); | ||||||
|
|
||||||
| // Install it | ||||||
| const result = await installer.install(script); | ||||||
|
|
@@ -180,7 +181,7 @@ export class CompletionCommand { | |||||
| // Prompt for confirmation unless --yes flag is provided | ||||||
| if (!skipConfirmation) { | ||||||
| const confirmed = await confirm({ | ||||||
| message: 'Remove OpenSpec configuration from ~/.zshrc?', | ||||||
| message: `Remove ${commandName} configuration from ~/.zshrc?`, | ||||||
|
||||||
| message: `Remove ${commandName} configuration from ~/.zshrc?`, | |
| message: `Remove ${commandName} configuration from ${shell} configuration?`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
getCommandName()function is defined but never used in this script. During postinstall, the completion script should be generated with the appropriate command name. Line 91 callsgenerator.generate(COMMAND_REGISTRY)without passing acommandNameparameter, which will default to 'openspec'. This means the installed completions will only work for theopenspeccommand, not forplx.