fix: cub -i interactive flag, -S auto-build on Linux
This commit is contained in:
@@ -104,6 +104,9 @@ struct Cli {
|
|||||||
/// Skip all interactive prompts (assume yes)
|
/// Skip all interactive prompts (assume yes)
|
||||||
#[arg(long = "noconfirm", global = true, action = clap::ArgAction::SetTrue)]
|
#[arg(long = "noconfirm", global = true, action = clap::ArgAction::SetTrue)]
|
||||||
noconfirm: bool,
|
noconfirm: bool,
|
||||||
|
/// Launch interactive TUI mode
|
||||||
|
#[arg(short = 'i', long = "interactive", global = true, action = clap::ArgAction::SetTrue)]
|
||||||
|
interactive: bool,
|
||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Option<Commands>,
|
command: Option<Commands>,
|
||||||
@@ -208,7 +211,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let context = AppContext::new();
|
let context = AppContext::new();
|
||||||
|
|
||||||
if let Some(command) = cli.command {
|
if let Some(command) = cli.command {
|
||||||
run_command(&context, command, cli.force, cli.noconfirm)?;
|
if cli.interactive {
|
||||||
|
launch_tui_or_help()?;
|
||||||
|
} else {
|
||||||
|
run_command(&context, command, cli.force, cli.noconfirm)?;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
launch_tui_or_help()?;
|
launch_tui_or_help()?;
|
||||||
}
|
}
|
||||||
@@ -348,7 +355,7 @@ fn rewrite_shortcut_args(
|
|||||||
fn leading_global_flag_count(rest: &[OsString]) -> usize {
|
fn leading_global_flag_count(rest: &[OsString]) -> usize {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
while let Some(flag) = rest.get(count).and_then(|value| value.to_str()) {
|
while let Some(flag) = rest.get(count).and_then(|value| value.to_str()) {
|
||||||
if matches!(flag, "-f" | "--force" | "--noconfirm") {
|
if matches!(flag, "-f" | "--force" | "--noconfirm" | "-i" | "--interactive") {
|
||||||
count += 1;
|
count += 1;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@@ -463,25 +470,30 @@ fn install_package(context: &AppContext, package: &str, force: bool, noconfirm:
|
|||||||
fs::remove_dir_all(&recipe_dir)?;
|
fs::remove_dir_all(&recipe_dir)?;
|
||||||
println!("Re-fetching {} (--force)...", pkg.name);
|
println!("Re-fetching {} (--force)...", pkg.name);
|
||||||
fetch_and_save_aur(pkg)?;
|
fetch_and_save_aur(pkg)?;
|
||||||
|
println!("Building {}...", pkg.name);
|
||||||
|
build_local_dir(context, &recipe_dir)?;
|
||||||
} else {
|
} else {
|
||||||
println!("Already cached in ~/.cub/recipes/{}/", pkg.name);
|
println!("Already cached — building {}...", pkg.name);
|
||||||
println!("Use --force/-f to re-fetch, or:");
|
build_local_dir(context, &recipe_dir)?;
|
||||||
println!(" cubl -B ~/.cub/recipes/{}/", pkg.name);
|
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if noconfirm {
|
if noconfirm {
|
||||||
fetch_and_save_aur(pkg)?;
|
fetch_and_save_aur(pkg)?;
|
||||||
|
println!("Building {}...", pkg.name);
|
||||||
|
build_local_dir(context, &recipe_dir)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Would you like to fetch this package from AUR into ~/.cub/? [y/N]");
|
println!("Would you like to fetch and build this package? [y/N]");
|
||||||
|
|
||||||
let mut answer = String::new();
|
let mut answer = String::new();
|
||||||
io::stdin().read_line(&mut answer)?;
|
io::stdin().read_line(&mut answer)?;
|
||||||
if answer.trim().to_ascii_lowercase().starts_with('y') {
|
if answer.trim().to_ascii_lowercase().starts_with('y') {
|
||||||
fetch_and_save_aur(pkg)?;
|
fetch_and_save_aur(pkg)?;
|
||||||
|
println!("Building {}...", pkg.name);
|
||||||
|
build_local_dir(context, &recipe_dir)?;
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user