diff options
Diffstat (limited to 'tool/src/add.rs')
-rw-r--r-- | tool/src/add.rs | 14 |
1 files changed, 11 insertions, 3 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() |