Skip to content

Commit 3f24eb5

Browse files
committed
Implement --additional-args option
1 parent d52af5a commit 3f24eb5

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/cargo.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ pub fn get_all_targets() -> Vec<Target> {
5959
convert(metadata, &current_dir)
6060
}
6161

62-
pub fn exec_cargo_run(target: &Target, action: &Action) -> ExitStatus {
62+
pub fn exec_cargo_run(
63+
target: &Target,
64+
action: &Action,
65+
additional_args: Option<String>,
66+
) -> ExitStatus {
6367
let action = match action {
6468
Action::Run => "run",
6569
Action::Build => "build",
@@ -80,6 +84,13 @@ pub fn exec_cargo_run(target: &Target, action: &Action) -> ExitStatus {
8084
cmd.arg("--features").arg(&features);
8185
};
8286

87+
if let Some(args) = additional_args {
88+
// todo: handle quoted arguments properly
89+
args.split_whitespace().for_each(|a| {
90+
cmd.arg(a);
91+
});
92+
}
93+
8394
eprintln!("{}", cmd_str(&cmd, require_features));
8495

8596
cmd.spawn()

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ struct SelectorArgs {
5454
/// Match type
5555
#[arg(short = 't', long, value_name = "TYPE")]
5656
match_type: Option<MatchType>,
57+
58+
/// Additional arguments
59+
#[arg(short, long, value_name = "ARGS", allow_hyphen_values = true)]
60+
additional_args: Option<String>,
5761
}
5862

5963
#[derive(Debug, Clone)]
@@ -155,6 +159,7 @@ fn main() -> std::io::Result<ExitCode> {
155159
inline_list_size,
156160
kind,
157161
match_type,
162+
additional_args,
158163
} = args;
159164

160165
let config = Config::load();
@@ -180,7 +185,7 @@ fn main() -> std::io::Result<ExitCode> {
180185
ret.map(|t| match t {
181186
Ret::Quit => ExitCode::SUCCESS,
182187
Ret::Selected(t, a) => {
183-
let status = cargo::exec_cargo_run(&t, &a);
188+
let status = cargo::exec_cargo_run(&t, &a, additional_args);
184189
to_exit_code(status)
185190
}
186191
Ret::NotSelected => {

0 commit comments

Comments
 (0)