diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-10 15:28:36 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-10 15:28:36 +0200 |
commit | 05d11426a8e60fa060733eb8ae7843bc2ae9725c (patch) | |
tree | 57cfad9cedf1eb50de193f1657b42234745c044e /tool | |
parent | c0365c8c64f403fd9ee75c0db1a9ed6134633e8f (diff) | |
download | jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.bz2 jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.zst |
apply many clippy issue
Diffstat (limited to 'tool')
-rw-r--r-- | tool/src/add.rs | 14 | ||||
-rw-r--r-- | tool/src/migrate.rs | 6 |
2 files changed, 14 insertions, 6 deletions
diff --git a/tool/src/add.rs b/tool/src/add.rs index dfec40d..7b3861e 100644 --- a/tool/src/add.rs +++ b/tool/src/add.rs @@ -55,6 +55,14 @@ pub async fn add(action: Action) -> anyhow::Result<()> { default = i }; } + TraktKind::Show => { + if let Some(i) = directories + .iter() + .position(|d| d.0.to_str().unwrap().contains("shows")) + { + default = i + }; + } _ => (), } } @@ -71,7 +79,7 @@ pub async fn add(action: Action) -> anyhow::Result<()> { let (last_search, trakt_object, trakt_kind) = loop { let name: String = Input::with_theme(&theme) .with_prompt("Search by title") - .default(media.as_ref().map(path_to_query).unwrap_or_default()) + .default(media.as_ref().map(|p| path_to_query(p)).unwrap_or_default()) .interact_text() .unwrap(); @@ -155,7 +163,7 @@ pub async fn add(action: Action) -> anyhow::Result<()> { } fn validate_id(s: &String) -> anyhow::Result<()> { - if &make_id(&s) == s { + if &make_id(s) == s { Ok(()) } else { bail!("invalid id") @@ -174,7 +182,7 @@ fn make_id(s: &str) -> String { out } -fn path_to_query(path: &PathBuf) -> String { +fn path_to_query(path: &Path) -> String { path.file_stem() .unwrap() .to_str() diff --git a/tool/src/migrate.rs b/tool/src/migrate.rs index 0412430..fe369d4 100644 --- a/tool/src/migrate.rs +++ b/tool/src/migrate.rs @@ -112,7 +112,7 @@ pub fn migrate(action: Action) -> anyhow::Result<()> { let table = txn.open_table(T_USER)?; let len = table.len()?; - for r in table.iter()?.progress_count(len.try_into().unwrap()) { + for r in table.iter()?.progress_count(len) { let (k, v) = r?; serde_json::to_writer(&mut o, &(k.value(), v.value().0))?; writeln!(&mut o)?; @@ -161,7 +161,7 @@ pub fn migrate(action: Action) -> anyhow::Result<()> { let table = txn.open_table(T_USER_NODE)?; let len = table.len()?; - for r in table.iter()?.progress_count(len.try_into().unwrap()) { + for r in table.iter()?.progress_count(len) { let (k, v) = r?; serde_json::to_writer(&mut o, &(k.value(), v.value().0))?; writeln!(&mut o)?; @@ -213,7 +213,7 @@ pub fn migrate(action: Action) -> anyhow::Result<()> { let table = txn.open_table(T_INVITE)?; let len = table.len()?; - for r in table.iter()?.progress_count(len.try_into().unwrap()) { + for r in table.iter()?.progress_count(len) { let (k, v) = r?; serde_json::to_writer(&mut o, &(k.value(), v.value().0))?; writeln!(&mut o)?; |