mirror of
https://github.com/denisidoro/navi
synced 2024-11-25 21:10:21 +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 mut writer = display::terminal::Writer::new();
|
||||||
|
|
||||||
let fetcher: Box<dyn Fetcher> = match config.source() {
|
let fetcher: Box<dyn Fetcher> = match config.source() {
|
||||||
Source::CHEATSH(query) => Box::new(cheatsh::Fetcher::new(query)),
|
Source::Cheats(query) => Box::new(cheatsh::Fetcher::new(query)),
|
||||||
Source::TLDR(query) => Box::new(tldr::Fetcher::new(query)),
|
Source::Tldr(query) => Box::new(tldr::Fetcher::new(query)),
|
||||||
Source::FILESYSTEM(path) => Box::new(filesystem::Fetcher::new(path)),
|
Source::Filesystem(path) => Box::new(filesystem::Fetcher::new(path)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = fetcher
|
let res = fetcher
|
||||||
|
@ -280,13 +280,13 @@ pub fn main(config: Config) -> Result<(), Error> {
|
||||||
);
|
);
|
||||||
|
|
||||||
match config.action() {
|
match config.action() {
|
||||||
Action::PRINT => {
|
Action::Print => {
|
||||||
println!("{}", interpolated_snippet);
|
println!("{}", interpolated_snippet);
|
||||||
}
|
}
|
||||||
Action::SAVE(filepath) => {
|
Action::Save(filepath) => {
|
||||||
fs::write(filepath, interpolated_snippet).context("Unable to save output")?;
|
fs::write(filepath, interpolated_snippet).context("Unable to save output")?;
|
||||||
}
|
}
|
||||||
Action::EXECUTE => match key {
|
Action::Execute => match key {
|
||||||
"ctrl-y" => {
|
"ctrl-y" => {
|
||||||
clipboard::copy(interpolated_snippet)?;
|
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 stdout = String::from_utf8(output.stdout).expect("Invalid utf8 output from stty");
|
||||||
let mut data = stdout.split_whitespace();
|
let mut data = stdout.split_whitespace();
|
||||||
data.next();
|
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,
|
_ => FALLBACK_WIDTH,
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn get_env_var(name: &str) -> String {
|
||||||
if let Ok(v) = env::var(name) {
|
if let Ok(v) = env::var(name) {
|
||||||
v
|
v
|
||||||
} else {
|
} 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) {
|
if let Some(v) = self.dependencies.get_mut(&k) {
|
||||||
v.push(fnv(&tags_dependency));
|
v.push(fnv(&tags_dependency));
|
||||||
} else {
|
} else {
|
||||||
let mut v: Vec<u64> = Vec::new();
|
let v: Vec<u64> = vec![fnv(&tags_dependency)];
|
||||||
v.push(fnv(&tags_dependency));
|
|
||||||
self.dependencies.insert(k, v);
|
self.dependencies.insert(k, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,35 +215,35 @@ pub enum AlfredCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Source {
|
pub enum Source {
|
||||||
FILESYSTEM(Option<String>),
|
Filesystem(Option<String>),
|
||||||
TLDR(String),
|
Tldr(String),
|
||||||
CHEATSH(String),
|
Cheats(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
SAVE(String),
|
Save(String),
|
||||||
PRINT,
|
Print,
|
||||||
EXECUTE,
|
Execute,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn source(&self) -> Source {
|
pub fn source(&self) -> Source {
|
||||||
if let Some(query) = self.tldr.clone() {
|
if let Some(query) = self.tldr.clone() {
|
||||||
Source::TLDR(query)
|
Source::Tldr(query)
|
||||||
} else if let Some(query) = self.cheatsh.clone() {
|
} else if let Some(query) = self.cheatsh.clone() {
|
||||||
Source::CHEATSH(query)
|
Source::Cheats(query)
|
||||||
} else {
|
} else {
|
||||||
Source::FILESYSTEM(self.path.clone())
|
Source::Filesystem(self.path.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn action(&self) -> Action {
|
pub fn action(&self) -> Action {
|
||||||
if let Some(filepath) = self.save.clone() {
|
if let Some(filepath) = self.save.clone() {
|
||||||
Action::SAVE(filepath)
|
Action::Save(filepath)
|
||||||
} else if self.print {
|
} else if self.print {
|
||||||
Action::PRINT
|
Action::Print
|
||||||
} else {
|
} else {
|
||||||
Action::EXECUTE
|
Action::Execute
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,8 +254,8 @@ impl Config {
|
||||||
}
|
}
|
||||||
if self.best_match {
|
if self.best_match {
|
||||||
match self.source() {
|
match self.source() {
|
||||||
Source::TLDR(q) => Some(q),
|
Source::Tldr(q) => Some(q),
|
||||||
Source::CHEATSH(q) => Some(q),
|
Source::Cheats(q) => Some(q),
|
||||||
_ => Some(String::from("")),
|
_ => Some(String::from("")),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue