Skip to content

Commit

Permalink
simplify, remove old selection method
Browse files Browse the repository at this point in the history
  • Loading branch information
keirlawson committed Jun 14, 2024
1 parent 91f8505 commit ef875c6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
34 changes: 25 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ anyhow = "1.0"
url = { version = "2", features = ["serde"] }
structopt = "0.3"
env_logger = "0.11"
fuzzy-select = { git = "https://github.com/knutwalker/fuzzy-select.git", rev = "7f785a728a584a6f154fe2ff910b28cf02b7df4c" }
fuzzy-select = "0.1.2"

[profile.release]
# per https://kobzol.github.io/rust/cargo/2024/01/23/making-rust-binaries-smaller-by-default.html
Expand Down
12 changes: 0 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::{anyhow, Context, Result};
use dialoguer::{theme::ColorfulTheme, Select};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
Expand Down Expand Up @@ -85,14 +84,3 @@ pub fn search_issues(config: Config, query: &str) -> Result<Vec<Issue>> {
resp.issues
.ok_or_else(|| anyhow!("No issues found for query"))
}

pub fn select_issue(issues: &[Issue]) -> Result<&Issue> {
let selection = Select::with_theme(&ColorfulTheme::default())
.items(issues)
.default(0)
.interact_opt()?;

let index = selection.ok_or_else(|| anyhow!("No JIRA issue selected"))?;

Ok(&issues[index])
}
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ fn main() -> Result<()> {
};
use fuzzy_select::FuzzySelect;

let selected = FuzzySelect::new()
.with_prompt("Select something")
.with_options(issues)
.select()?;
let selected = FuzzySelect::new().with_options(issues).select()?;

println!("{}", selected.key);

Expand Down

0 comments on commit ef875c6

Please sign in to comment.