Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
coman/src/config.rs
Outdated
| #[serde(default)] | ||
| pub coman_squash_path: Option<PathBuf>, | ||
| #[serde(default)] | ||
| pub update_check_interval: u64, |
There was a problem hiding this comment.
Missing default value for update_check_interval; this will cause a panic if not explicitly set in config.
| pub update_check_interval: u64, | |
| pub update_check_interval: u64 = 3600; |
#ai-review-inline
| app::{ | ||
| Cli, CliCommands, ConfigCommands, CscsCommands, CscsFileCommands, CscsJobCommands, CscsSystemCommands, | ||
| get_config, print_completions, set_config, version, | ||
| check_update, get_config, print_completions, set_config, update, version, |
There was a problem hiding this comment.
Added 'update' function to CLI commands, ensure it's properly implemented and tested.
| check_update, get_config, print_completions, set_config, update, version, | |
| check_update, get_config, print_completions, set_config, update, version, |
#ai-review-inline
coman/src/main.rs
Outdated
| CompleteEnv::with_factory(Cli::command).complete(); | ||
|
|
||
| // check self-update | ||
| check_update().await; |
There was a problem hiding this comment.
The check_update call should handle errors gracefully to avoid silent failures.
| check_update().await; | |
| check_update().await; |
#ai-review-inline
|
|
||
| [cscs] | ||
| # check https://docs.cscs.ch/access/firecrest/#firecrest-deployment-on-alps for possible system and platform combinations | ||
| current_system = "daint" # what system/cluster to execute commands on |
There was a problem hiding this comment.
The comment references external documentation; consider adding a brief explanation of what 'current_system' controls.
| current_system = "daint" # what system/cluster to execute commands on | |
| current_system = "daint" # Specifies the target cluster for command execution |
#ai-review-inline
| @@ -1,3 +1,5 @@ | |||
| update_check_interval_hours = 24 | |||
There was a problem hiding this comment.
Consider using a more descriptive comment explaining why this interval was chosen.
| update_check_interval_hours = 24 | |
| update_check_interval_hours = 24 # Check for updates every 24 hours |
#ai-review-inline
coman/src/cli/app.rs
Outdated
| Ok(()) | ||
| } | ||
|
|
||
| pub async fn check_update() -> () { |
There was a problem hiding this comment.
Function signature should return Result<(), Report> for better error handling consistency.
| pub async fn check_update() -> () { | |
| pub async fn check_update() -> Result<()> { |
#ai-review-inline
coman/src/cli/app.rs
Outdated
| if now.naive_local() - update_stamp.naive_local() > TimeDelta::hours(config.values.update_check_interval as i64) { | ||
| println!("checking for updates"); | ||
| let _ = update(); | ||
| std::fs::write(&stamp_path, Local::now().to_rfc3339()).unwrap(); |
There was a problem hiding this comment.
Using unwrap() can cause panic; prefer proper error handling with ? operator.
| std::fs::write(&stamp_path, Local::now().to_rfc3339()).unwrap(); | |
| std::fs::write(&stamp_path, Local::now().to_rfc3339()).map_err(|e| Report::msg(format!("Failed to update stamp file: {}", e)))?; |
#ai-review-inline
coman/src/cli/app.rs
Outdated
| let now = Local::now(); | ||
| if now.naive_local() - update_stamp.naive_local() > TimeDelta::hours(config.values.update_check_interval as i64) { | ||
| println!("checking for updates"); | ||
| let _ = update(); |
There was a problem hiding this comment.
Ignoring the result of update() may hide potential update failures; consider logging or propagating the error.
| let _ = update(); | |
| let result = update(); if let Err(e) = result { eprintln!("Update failed: {}", e); } |
#ai-review-inline
coman/src/cli/app.rs
Outdated
| }; | ||
|
|
||
| let now = Local::now(); | ||
| if now.naive_local() - update_stamp.naive_local() > TimeDelta::hours(config.values.update_check_interval as i64) { |
There was a problem hiding this comment.
The time comparison may overflow if the interval is too large; consider using checked arithmetic.
| if now.naive_local() - update_stamp.naive_local() > TimeDelta::hours(config.values.update_check_interval as i64) { | |
| if (now.naive_local() - update_stamp.naive_local()).num_hours() > config.values.update_check_interval as i64 { |
#ai-review-inline
| let data_dir = get_data_dir(); | ||
| let stamp_path = data_dir.join("selfupdate.stamp"); | ||
| let Ok(update_stamp) = std::fs::read_to_string(&stamp_path) else { | ||
| std::fs::write(&stamp_path, Local::now().to_rfc3339()).unwrap(); |
There was a problem hiding this comment.
Using unwrap() can cause panic; prefer proper error handling with ? operator.
| std::fs::write(&stamp_path, Local::now().to_rfc3339()).unwrap(); | |
| std::fs::write(&stamp_path, Local::now().to_rfc3339()).map_err(|e| Report::msg(format!("Failed to write stamp file: {}", e)))?; |
#ai-review-inline
db3f045 to
1281c8f
Compare
1281c8f to
d5a2732
Compare
No description provided.