Skip to content

Commit

Permalink
chore: install workflow-runner via axo (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante authored Aug 15, 2024
1 parent 07fe150 commit d3c76b3
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 361 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ uuid = { version = "1.1", features = ["v4", "serde"] }
tokio = { version = "1", features = ["full"] }
chrono = { version = "0.4.26", features = ["serde"] }
reqwest = { version = "0.11", features = ["json", "stream"] }
futures-util = { version = "0.3.30" }
lazy_static = { version = "1.4.0" }
indicatif-log-bridge = { version = "0.2.1" }
colored = { version = "2.0.4" }
Expand Down
28 changes: 6 additions & 22 deletions crates/cli/src/commands/install.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use anyhow::Result;
use anyhow::{Result};
use clap::Args;
use log::info;
use serde::Serialize;

use crate::{
updater::{SupportedApp, Updater},
utils::{get_client_arch, get_client_os, Architecture, OperatingSystem},
};
use crate::updater::{SupportedApp, Updater};

#[derive(Args, Debug, Serialize)]
pub struct InstallArgs {
Expand All @@ -16,25 +13,12 @@ pub struct InstallArgs {
/// Specify a specific app to install
#[clap(long = "app")]
app: Option<SupportedApp>,
/// Override the architecture to install
#[clap(long = "arch", hide = true)]
arch: Option<Architecture>,
/// Override the OS to install for
#[clap(long = "os", hide = true)]
os: Option<OperatingSystem>,
}

pub(crate) async fn run_install(arg: InstallArgs) -> Result<()> {
let should_update = arg.update;
let mut updater = Updater::from_current_bin().await?;

let arch = arg
.arch
.map_or_else(|| get_client_arch().to_string(), |arch| arch.to_string());
let os = arg
.os
.map_or_else(|| get_client_os().to_string(), |os| format!("{}", &os));

info!(
"Targeting {} as install directory",
updater.install_path.display()
Expand All @@ -45,13 +29,13 @@ pub(crate) async fn run_install(arg: InstallArgs) -> Result<()> {
true => match should_update {
true => {
info!("{} already present, installing latest", app);
updater.install_latest(app, Some(&os), Some(&arch)).await?;
updater.install_latest(app).await?;
}
false => info!("{} already present, skipping", app),
},
false => {
info!("{} not present, installing", app);
updater.install_latest(app, Some(&os), Some(&arch)).await?;
updater.install_latest(app).await?;
}
}
// TODO: output *only* the installed binary path to stdout
Expand All @@ -63,14 +47,14 @@ pub(crate) async fn run_install(arg: InstallArgs) -> Result<()> {
true => match should_update {
true => {
info!("{} already present, installing latest", app);
updater.install_latest(app, Some(&os), Some(&arch)).await?;
updater.install_latest(app).await?;
}
false => info!("{} already present, skipping", app),
},
false => {
if app.is_default_app() {
info!("{} not present, installing", app);
updater.install_latest(app, Some(&os), Some(&arch)).await?;
updater.install_latest(app).await?;
} else {
info!("{app} not present, skipping, run with --app {app} to install",);
}
Expand Down
Loading

0 comments on commit d3c76b3

Please sign in to comment.