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
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ jobs:
os: ubuntu-latest
target: x86_64-unknown-linux-musl
bin: coman
name: coman-Linux-x86_64-musl.tar.gz
name: coman-x86_64-unknown-linux-musl.tar.gz
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for the Linux x86_64 artifact has been updated for consistency.

Suggested change
name: coman-x86_64-unknown-linux-musl.tar.gz
name: coman-x86_64-unknown-linux-musl.tar.gz

#ai-review-inline

cargo_command: cargo
squash: true

- os_name: Linux-aarch64
os: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
bin: coman
name: coman-Linux-aarch64-musl.tar.gz
name: coman-aarch64-unknown-linux-musl.tar.gz
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for the Linux aarch64 artifact has been updated for consistency.

Suggested change
name: coman-aarch64-unknown-linux-musl.tar.gz
name: coman-aarch64-unknown-linux-musl.tar.gz

#ai-review-inline

cargo_command: cargo
squash: true

- os_name: Windows-aarch64
os: windows-latest
target: aarch64-pc-windows-msvc
bin: coman.exe
name: coman-Windows-aarch64.zip
name: coman-aarch64-pc-windows-msvc.zip
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for the Windows aarch64 artifact has been updated for consistency.

Suggested change
name: coman-aarch64-pc-windows-msvc.zip
name: coman-aarch64-pc-windows-msvc.zip

#ai-review-inline

cargo_command: cargo
squash: false

- os_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
bin: coman
name: coman-Darwin-x86_64.tar.gz
name: coman-x86_64-apple-darwin.tar.gz
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for the macOS x86_64 artifact has been updated for consistency.

Suggested change
name: coman-x86_64-apple-darwin.tar.gz
name: coman-x86_64-apple-darwin.tar.gz

#ai-review-inline

cargo_command: cargo
squash: false

Expand Down
141 changes: 140 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions coman/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ tarpc = { version = "0.37.0", features = [
tokio-duplex = "1.0.1"
sysinfo = "0.38.0"
bytesize = "2.3.1"
self_update = { version = "0.42.0", features = ["archive-tar", "archive-zip"] }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added self_update crate with archive features, ensure these features are necessary for the intended use case.

Suggested change
self_update = { version = "0.42.0", features = ["archive-tar", "archive-zip"] }
self_update = { version = "0.42.0", features = ["archive-tar", "archive-zip"] }

#ai-review-inline


[build-dependencies]
anyhow = "1.0.90"
Expand Down
2 changes: 2 additions & 0 deletions coman/src/cli/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub struct Cli {
pub enum CliCommands {
#[clap(about = "Show version and config file locations")]
Version,
#[clap(about = "Self-update coman. Experimental", hide = true)]
Update,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Update command is marked as experimental and hidden, which might cause confusion for users expecting it to be available.

#ai-review-inline

#[clap(about = "Subcommands related to CSCS")]
Cscs {
#[command(subcommand)]
Expand Down
24 changes: 24 additions & 0 deletions coman/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use clap::{CommandFactory, Parser};
use clap_complete::CompleteEnv;
use color_eyre::Result;
use keyring::set_global_service_name;
use self_update::cargo_crate_version;
use tokio::{runtime::Handle, sync::mpsc};
use tuirealm::{
Application, EventListenerCfg, PollStrategy, Sub, SubClause, SubEventClause, Update,
Expand Down Expand Up @@ -67,6 +68,12 @@ async fn main() -> Result<()> {
match args.command {
Some(command) => match command {
CliCommands::Version => println!("{}", version()),
CliCommands::Update => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the update task instead of using unwrap().

Suggested change
CliCommands::Update => {
tokio::task::spawn_blocking(move || {
if let Err(e) = update() {
eprintln!("Update failed: {}", e);
}
}).await?

#ai-review-inline

tokio::task::spawn_blocking(move || {
update().unwrap();
})
.await?
}
CliCommands::Completions { generator } => {
let mut cmd = Cli::command();
print_completions(generator, &mut cmd);
Expand Down Expand Up @@ -372,3 +379,20 @@ fn popup_exclusion_clause() -> SubClause<Id> {
SubClause::IsMounted(Id::SystemSelectPopup),
])))
}

fn update() -> Result<()> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update function should handle errors more gracefully instead of panicking with unwrap().

Suggested change
fn update() -> Result<()> {
fn update() -> Result<()> {
let status = self_update::backends::github::Update::configure()
.repo_owner("SwissDataScienceCenter")
.repo_name("coman")
.bin_name("coman")
.show_download_progress(true)
.current_version(cargo_crate_version!())
.build()?;
let status = status.update()?;
println!("Update status: `{}`", status.version());
Ok(())
}

#ai-review-inline

let status = self_update::backends::github::Update::configure()
.repo_owner("SwissDataScienceCenter")
.repo_name("coman")
.bin_name("coman")
.show_download_progress(true)
.current_version(cargo_crate_version!())
.build()?
.update()?;
if status.updated() {
println!("Successfully updated to version: `{}`", status.version());
} else {
println!("Already up to date at version: `{}`", status.version());
}
Ok(())
}