Skip to content

Commit

Permalink
Fix warnings (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
denisidoro authored Apr 4, 2021
1 parent c35e20e commit 347c19d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
12 changes: 6 additions & 6 deletions src/cmds/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)?;
}
Expand Down
5 changes: 4 additions & 1 deletion src/common/terminal_width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion src/display/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/structures/cheat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/structures/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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 {
Expand Down

0 comments on commit 347c19d

Please # to comment.