Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub enum Commands {
package: String,
#[arg(short, long)]
force: bool,
#[arg(long)]
dry_run: bool,
},
List {
#[arg(short, long)]
Expand Down
22 changes: 20 additions & 2 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ use crate::github::{find_matching_asset, parse_package, Asset, GithubClient, Pla
use crate::registry::{InstalledPackage, Registry};
use crate::util::{bin_dir_from, registry_path_from};

pub async fn handle_install(package: &str, force: bool, config: &Config) -> Result<()> {
pub async fn handle_install(
package: &str,
force: bool,
dry_run: bool,
config: &Config,
) -> Result<()> {
let (owner, repo, version) = parse_package(package)?;
let key = format!("{}/{}", owner, repo);

Expand All @@ -32,6 +37,19 @@ pub async fn handle_install(package: &str, force: bool, config: &Config) -> Resu

let asset = select_best_asset(&release)?;

let pkg_install_dir = config.install_dir.join("packages").join(&key);
let bin_dir = bin_dir_from(&config.install_dir);

if dry_run {
println!("[DRY RUN] Would install {}:", key);
println!(" Release: {}", release.tag_name);
println!(" Asset: {}", asset.name);
println!(" Install dir: {}", pkg_install_dir.display());
println!(" Binary: {}/{}", pkg_install_dir.display(), repo);
println!(" Symlink: {}/{}", bin_dir.display(), repo);
return Ok(());
}

if !config.output.quiet {
println!("Release: {}", release.tag_name);
println!("Asset: {}", asset.name);
Expand Down Expand Up @@ -114,7 +132,7 @@ async fn update_one(package: &str, config: &Config) -> Result<()> {
);
}
crate::registry::uninstall(package, &config.install_dir)?;
handle_install(package, false, config).await
handle_install(package, false, false, config).await
}

async fn update_all(config: &Config) -> Result<()> {
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ fn apply_cli_overrides(mut config: Config, cli: &Cli) -> Config {

async fn run(cli: Cli, config: Config) -> anyhow::Result<()> {
match cli.command {
Commands::Install { package, force } => {
install::handle_install(&package, force, &config).await?
}
Commands::Install {
package,
force,
dry_run,
} => install::handle_install(&package, force, dry_run, &config).await?,
Commands::List { verbose } => registry::list_installed(verbose)?,
Commands::Update { package } => install::handle_update(package.as_deref(), &config).await?,
Commands::Uninstall { package } => registry::uninstall(&package, &config.install_dir)?,
Expand Down
Loading