mirror of
https://github.com/denisidoro/navi
synced 2024-11-25 13:00:20 +00:00
Fix warnings (#464)
This commit is contained in:
parent
c35e20e778
commit
347c19ddca
5 changed files with 26 additions and 24 deletions
|
@ -233,9 +233,9 @@ pub fn main(config: Config) -> Result<(), Error> {
|
|||
let mut writer = display::terminal::Writer::new();
|
||||
|
||||
let fetcher: Box<dyn Fetcher> = match config.source() {
|
||||
Source::CHEATSH(query) => Box::new(cheatsh::Fetcher::new(query)),
|
||||
Source::TLDR(query) => Box::new(tldr::Fetcher::new(query)),
|
||||
Source::FILESYSTEM(path) => Box::new(filesystem::Fetcher::new(path)),
|
||||
Source::Cheats(query) => Box::new(cheatsh::Fetcher::new(query)),
|
||||
Source::Tldr(query) => Box::new(tldr::Fetcher::new(query)),
|
||||
Source::Filesystem(path) => Box::new(filesystem::Fetcher::new(path)),
|
||||
};
|
||||
|
||||
let res = fetcher
|
||||
|
@ -280,13 +280,13 @@ pub fn main(config: Config) -> Result<(), Error> {
|
|||
);
|
||||
|
||||
match config.action() {
|
||||
Action::PRINT => {
|
||||
Action::Print => {
|
||||
println!("{}", interpolated_snippet);
|
||||
}
|
||||
Action::SAVE(filepath) => {
|
||||
Action::Save(filepath) => {
|
||||
fs::write(filepath, interpolated_snippet).context("Unable to save output")?;
|
||||
}
|
||||
Action::EXECUTE => match key {
|
||||
Action::Execute => match key {
|
||||
"ctrl-y" => {
|
||||
clipboard::copy(interpolated_snippet)?;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,10 @@ fn width_with_shell_out() -> u16 {
|
|||
let stdout = String::from_utf8(output.stdout).expect("Invalid utf8 output from stty");
|
||||
let mut data = stdout.split_whitespace();
|
||||
data.next();
|
||||
u16::from_str_radix(data.next().expect("Not enough data"), 10).expect("Invalid base-10 number")
|
||||
data.next()
|
||||
.expect("Not enough data")
|
||||
.parse::<u16>()
|
||||
.expect("Invalid base-10 number")
|
||||
}
|
||||
_ => FALLBACK_WIDTH,
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ fn get_env_var(name: &str) -> String {
|
|||
if let Ok(v) = env::var(name) {
|
||||
v
|
||||
} else {
|
||||
panic!(format!("{} not set", name))
|
||||
panic!("{} not set", name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ impl VariableMap {
|
|||
if let Some(v) = self.dependencies.get_mut(&k) {
|
||||
v.push(fnv(&tags_dependency));
|
||||
} else {
|
||||
let mut v: Vec<u64> = Vec::new();
|
||||
v.push(fnv(&tags_dependency));
|
||||
let v: Vec<u64> = vec![fnv(&tags_dependency)];
|
||||
self.dependencies.insert(k, v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,35 +215,35 @@ pub enum AlfredCommand {
|
|||
}
|
||||
|
||||
pub enum Source {
|
||||
FILESYSTEM(Option<String>),
|
||||
TLDR(String),
|
||||
CHEATSH(String),
|
||||
Filesystem(Option<String>),
|
||||
Tldr(String),
|
||||
Cheats(String),
|
||||
}
|
||||
|
||||
pub enum Action {
|
||||
SAVE(String),
|
||||
PRINT,
|
||||
EXECUTE,
|
||||
Save(String),
|
||||
Print,
|
||||
Execute,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn source(&self) -> Source {
|
||||
if let Some(query) = self.tldr.clone() {
|
||||
Source::TLDR(query)
|
||||
Source::Tldr(query)
|
||||
} else if let Some(query) = self.cheatsh.clone() {
|
||||
Source::CHEATSH(query)
|
||||
Source::Cheats(query)
|
||||
} else {
|
||||
Source::FILESYSTEM(self.path.clone())
|
||||
Source::Filesystem(self.path.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn action(&self) -> Action {
|
||||
if let Some(filepath) = self.save.clone() {
|
||||
Action::SAVE(filepath)
|
||||
Action::Save(filepath)
|
||||
} else if self.print {
|
||||
Action::PRINT
|
||||
Action::Print
|
||||
} else {
|
||||
Action::EXECUTE
|
||||
Action::Execute
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,8 +254,8 @@ impl Config {
|
|||
}
|
||||
if self.best_match {
|
||||
match self.source() {
|
||||
Source::TLDR(q) => Some(q),
|
||||
Source::CHEATSH(q) => Some(q),
|
||||
Source::Tldr(q) => Some(q),
|
||||
Source::Cheats(q) => Some(q),
|
||||
_ => Some(String::from("")),
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue