feat(cli): Introduce arguments for shell execution in custom commands (#5966)

This commit is contained in:
Abhi
2025-08-17 00:02:54 -04:00
committed by GitHub
parent e7dbc607a5
commit 33b9bdb11e
12 changed files with 1201 additions and 218 deletions
+12 -10
View File
@@ -21,10 +21,7 @@ import {
SlashCommand,
SlashCommandActionReturn,
} from '../ui/commands/types.js';
import {
DefaultArgumentProcessor,
ShorthandArgumentProcessor,
} from './prompt-processors/argumentProcessor.js';
import { DefaultArgumentProcessor } from './prompt-processors/argumentProcessor.js';
import {
IPromptProcessor,
SHORTHAND_ARGS_PLACEHOLDER,
@@ -224,16 +221,21 @@ export class FileCommandLoader implements ICommandLoader {
}
const processors: IPromptProcessor[] = [];
const usesArgs = validDef.prompt.includes(SHORTHAND_ARGS_PLACEHOLDER);
const usesShellInjection = validDef.prompt.includes(
SHELL_INJECTION_TRIGGER,
);
// Add the Shell Processor if needed.
if (validDef.prompt.includes(SHELL_INJECTION_TRIGGER)) {
// Interpolation (Shell Execution and Argument Injection)
// If the prompt uses either shell injection OR argument placeholders,
// we must use the ShellProcessor.
if (usesShellInjection || usesArgs) {
processors.push(new ShellProcessor(baseCommandName));
}
// The presence of '{{args}}' is the switch that determines the behavior.
if (validDef.prompt.includes(SHORTHAND_ARGS_PLACEHOLDER)) {
processors.push(new ShorthandArgumentProcessor());
} else {
// Default Argument Handling
// If NO explicit argument injection ({{args}}) was used, we append the raw invocation.
if (!usesArgs) {
processors.push(new DefaultArgumentProcessor());
}