Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2e109c7

Browse files
committed
refactor: Use a single CLI args array rather than a separate subcommand field
1 parent d472fd9 commit 2e109c7

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

editors/code/src/run.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise
115115

116116
const definition: tasks.RustTargetDefinition = {
117117
type: tasks.TASK_TYPE,
118-
command: args[0], // run, test, etc...
119-
args: args.slice(1),
118+
args,
120119
cwd: runnable.args.workspaceRoot || ".",
121120
env: prepareEnv(runnable, config.runnablesExtraEnv),
122121
overrideCargo: runnable.args.overrideCargo,
@@ -128,7 +127,6 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise
128127
target,
129128
definition,
130129
runnable.label,
131-
args,
132130
config.problemMatcher,
133131
config.cargoRunner,
134132
true,

editors/code/src/tasks.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ export const TASK_TYPE = "cargo";
1010
export const TASK_SOURCE = "rust";
1111

1212
export interface RustTargetDefinition extends vscode.TaskDefinition {
13-
command?: string;
14-
args?: string[];
13+
args: string[];
1514
cwd?: string;
1615
env?: { [key: string]: string };
1716
overrideCargo?: string;
@@ -44,9 +43,8 @@ class RustTaskProvider implements vscode.TaskProvider {
4443
for (const def of defs) {
4544
const vscodeTask = await buildRustTask(
4645
workspaceTarget,
47-
{ type: TASK_TYPE, command: def.command },
46+
{ type: TASK_TYPE, args: [def.command] },
4847
`cargo ${def.command}`,
49-
[def.command],
5048
this.config.problemMatcher,
5149
this.config.cargoRunner,
5250
);
@@ -65,13 +63,11 @@ class RustTaskProvider implements vscode.TaskProvider {
6563

6664
const definition = task.definition as RustTargetDefinition;
6765

68-
if (definition.type === TASK_TYPE && definition.command) {
69-
const args = [definition.command].concat(definition.args ?? []);
66+
if (definition.type === TASK_TYPE) {
7067
return await buildRustTask(
7168
task.scope,
7269
definition,
7370
task.name,
74-
args,
7571
this.config.problemMatcher,
7672
this.config.cargoRunner,
7773
);
@@ -85,7 +81,6 @@ export async function buildRustTask(
8581
scope: vscode.WorkspaceFolder | vscode.TaskScope | undefined,
8682
definition: RustTargetDefinition,
8783
name: string,
88-
args: string[],
8984
problemMatcher: string[],
9085
customRunner?: string,
9186
throwOnError: boolean = false,
@@ -95,7 +90,12 @@ export async function buildRustTask(
9590
if (customRunner) {
9691
const runnerCommand = `${customRunner}.buildShellExecution`;
9792
try {
98-
const runnerArgs = { kind: TASK_TYPE, args, cwd: definition.cwd, env: definition.env };
93+
const runnerArgs = {
94+
kind: TASK_TYPE,
95+
args: definition.args,
96+
cwd: definition.cwd,
97+
env: definition.env,
98+
};
9999
const customExec = await vscode.commands.executeCommand(runnerCommand, runnerArgs);
100100
if (customExec) {
101101
if (customExec instanceof vscode.ShellExecution) {
@@ -119,7 +119,7 @@ export async function buildRustTask(
119119
const cargoPath = await toolchain.cargoPath();
120120
const cargoCommand = overrideCargo?.split(" ") ?? [cargoPath];
121121

122-
const fullCommand = [...cargoCommand, ...args];
122+
const fullCommand = [...cargoCommand, ...definition.args];
123123

124124
const processName = unwrapUndefinable(fullCommand[0]);
125125
exec = new vscode.ProcessExecution(processName, fullCommand.slice(1), definition);

0 commit comments

Comments
 (0)