From 8514c52e935547c8fda6cfc4c9f56e5f697189c0 Mon Sep 17 00:00:00 2001 From: G2-Games Date: Sat, 9 Nov 2024 17:50:03 -0600 Subject: [PATCH] Made binary `imu` --- confetti-cli/Cargo.toml | 4 ++++ confetti-cli/src/main.rs | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/confetti-cli/Cargo.toml b/confetti-cli/Cargo.toml index 5632bc7..d872f10 100644 --- a/confetti-cli/Cargo.toml +++ b/confetti-cli/Cargo.toml @@ -9,6 +9,10 @@ authors.workspace = true license = "AGPL-3.0-or-later" edition = "2021" +[[bin]] +name = "imu" +path = "src/main.rs" + [lints] workspace = true diff --git a/confetti-cli/src/main.rs b/confetti-cli/src/main.rs index 99acffe..05691ac 100644 --- a/confetti-cli/src/main.rs +++ b/confetti-cli/src/main.rs @@ -33,6 +33,7 @@ struct Cli { #[derive(Subcommand)] enum Commands { /// Upload files + #[command(visible_alias="u")] Upload { /// Filename(s) to upload #[arg(value_name = "file(s)", required = true)] @@ -107,6 +108,11 @@ async fn main() -> Result<()> { println!("Uploading..."); for path in files { + if !path.try_exists().is_ok_and(|t| t) { + print_error_line(format!("The file {:#?} does not exist", path.truecolor(234, 129, 100))); + continue; + } + let name = path.file_name().unwrap().to_string_lossy(); let response = upload_file( name.into_owned(), @@ -633,7 +639,7 @@ fn pretty_time_long(seconds: i64) -> String { } fn exit_error(main_message: String, fix: Option, fix_values: Option>) -> ! { - eprintln!("{}: {main_message}\n", "Error".truecolor(181,66,127).italic().underline()); + print_error_line(main_message); if let Some(f) = fix { eprint!("{f} "); @@ -652,3 +658,7 @@ fn exit_error(main_message: String, fix: Option, fix_values: Option