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)
|
||||
#[arg(long = "noconfirm", global = true, action = clap::ArgAction::SetTrue)]
|
||||
noconfirm: bool,
|
||||
/// Launch interactive TUI mode
|
||||
#[arg(short = 'i', long = "interactive", global = true, action = clap::ArgAction::SetTrue)]
|
||||
interactive: bool,
|
||||
|
||||
#[command(subcommand)]
|
||||
command: Option<Commands>,
|
||||
@@ -208,7 +211,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let context = AppContext::new();
|
||||
|
||||
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 {
|
||||
launch_tui_or_help()?;
|
||||
}
|
||||
@@ -348,7 +355,7 @@ fn rewrite_shortcut_args(
|
||||
fn leading_global_flag_count(rest: &[OsString]) -> usize {
|
||||
let mut count = 0;
|
||||
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;
|
||||
} else {
|
||||
break;
|
||||
@@ -463,25 +470,30 @@ fn install_package(context: &AppContext, package: &str, force: bool, noconfirm:
|
||||
fs::remove_dir_all(&recipe_dir)?;
|
||||
println!("Re-fetching {} (--force)...", pkg.name);
|
||||
fetch_and_save_aur(pkg)?;
|
||||
println!("Building {}...", pkg.name);
|
||||
build_local_dir(context, &recipe_dir)?;
|
||||
} else {
|
||||
println!("Already cached in ~/.cub/recipes/{}/", pkg.name);
|
||||
println!("Use --force/-f to re-fetch, or:");
|
||||
println!(" cubl -B ~/.cub/recipes/{}/", pkg.name);
|
||||
println!("Already cached — building {}...", pkg.name);
|
||||
build_local_dir(context, &recipe_dir)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if noconfirm {
|
||||
fetch_and_save_aur(pkg)?;
|
||||
println!("Building {}...", pkg.name);
|
||||
build_local_dir(context, &recipe_dir)?;
|
||||
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();
|
||||
io::stdin().read_line(&mut answer)?;
|
||||
if answer.trim().to_ascii_lowercase().starts_with('y') {
|
||||
fetch_and_save_aur(pkg)?;
|
||||
println!("Building {}...", pkg.name);
|
||||
build_local_dir(context, &recipe_dir)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user