From 54018f977325f6f5a04ff273e0f09a90126f5d5d Mon Sep 17 00:00:00 2001 From: ByteDream Date: Thu, 8 Dec 2022 01:37:37 +0100 Subject: [PATCH] Fmt --- crunchy-cli-core/src/cli/download.rs | 7 ++++++- crunchy-cli-core/src/lib.rs | 10 +++++++--- crunchy-cli-core/src/utils/os.rs | 8 +++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/crunchy-cli-core/src/cli/download.rs b/crunchy-cli-core/src/cli/download.rs index 393e45a..ddf45b3 100644 --- a/crunchy-cli-core/src/cli/download.rs +++ b/crunchy-cli-core/src/cli/download.rs @@ -68,7 +68,12 @@ impl Execute for Download { fn pre_check(&self) -> Result<()> { if has_ffmpeg() { debug!("FFmpeg detected") - } else if PathBuf::from(&self.output).extension().unwrap_or_default().to_string_lossy() != "ts" { + } else if PathBuf::from(&self.output) + .extension() + .unwrap_or_default() + .to_string_lossy() + != "ts" + { bail!("File extension is not '.ts'. If you want to use a custom file format, please install ffmpeg") } diff --git a/crunchy-cli-core/src/lib.rs b/crunchy-cli-core/src/lib.rs index 2e0cf4d..92a076f 100644 --- a/crunchy-cli-core/src/lib.rs +++ b/crunchy-cli-core/src/lib.rs @@ -12,11 +12,13 @@ use std::{env, fs}; mod cli; mod utils; -pub use cli::{archive::Archive, download::Download, login::Login}; +pub use cli::{archive::Archive, download::Download, login::Login, search::Search}; #[async_trait::async_trait(?Send)] trait Execute { - fn pre_check(&self) -> Result<()> { Ok(()) } + fn pre_check(&self) -> Result<()> { + Ok(()) + } async fn execute(self, ctx: Context) -> Result<()>; } @@ -57,6 +59,7 @@ enum Command { Archive(Archive), Download(Download), Login(Login), + Search(Search), } #[derive(Debug, Parser)] @@ -153,7 +156,7 @@ pub async fn cli_entrypoint() { debug!("Created ctrl-c handler"); match cli.command { - Command::Archive(archive) => execute_executor(archive,ctx).await, + Command::Archive(archive) => execute_executor(archive, ctx).await, Command::Download(download) => execute_executor(download, ctx).await, Command::Login(login) => { if login.remove { @@ -162,6 +165,7 @@ pub async fn cli_entrypoint() { execute_executor(login, ctx).await } } + Command::Search(search) => execute_executor(search, ctx).await, }; } diff --git a/crunchy-cli-core/src/utils/os.rs b/crunchy-cli-core/src/utils/os.rs index 4919c08..c6e262e 100644 --- a/crunchy-cli-core/src/utils/os.rs +++ b/crunchy-cli-core/src/utils/os.rs @@ -44,8 +44,8 @@ pub fn free_file(mut path: PathBuf) -> PathBuf { let ext = path.extension().unwrap().to_string_lossy(); let mut filename = path.file_stem().unwrap().to_str().unwrap(); - if filename.ends_with(&format!(" ({})", i-1)) { - filename = filename.strip_suffix(&format!(" ({})", i-1)).unwrap(); + if filename.ends_with(&format!(" ({})", i - 1)) { + filename = filename.strip_suffix(&format!(" ({})", i - 1)).unwrap(); } path.set_file_name(format!("{} ({}).{}", filename, i, ext)) @@ -55,5 +55,7 @@ pub fn free_file(mut path: PathBuf) -> PathBuf { /// Sanitizes the given path to not contain any invalid file character. pub fn sanitize_file(path: PathBuf) -> PathBuf { - path.with_file_name(sanitize_filename::sanitize(path.file_name().unwrap().to_string_lossy())) + path.with_file_name(sanitize_filename::sanitize( + path.file_name().unwrap().to_string_lossy(), + )) }