summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2023-04-08 19:28:42 -0300
committerGitHub <noreply@github.com>2023-04-08 19:28:42 -0300
commit8cf9c96e542a79c891c7f4be5095b9752eeec6c1 (patch)
tree1e267bb3ecbb3dab6e7ba657a8022847d614f338 /src
parent7abdb057e66e292fc39e7ab5253348500085efa0 (diff)
Update dependencies (#817)
Diffstat (limited to 'src')
-rw-r--r--src/clients/cheatsh.rs4
-rw-r--r--src/clients/tldr.rs2
-rw-r--r--src/commands/core/actor.rs4
-rw-r--r--src/commands/func/widget.rs4
-rw-r--r--src/commands/preview/var.rs2
-rw-r--r--src/commands/repo/browse.rs2
-rw-r--r--src/common/component.rs.bkp21
-rw-r--r--src/common/deps.rs.bkp7
-rw-r--r--src/common/deser.rs.bkp50
-rw-r--r--src/common/git.rs2
-rw-r--r--src/common/shell.rs2
-rw-r--r--src/common/system.rs.bkp57
-rw-r--r--src/common/tracing.rs.bkp36
-rw-r--r--src/filesystem.rs4
-rw-r--r--src/finder/mod.rs26
-rw-r--r--src/finder/post.rs2
-rw-r--r--src/parser.rs4
-rw-r--r--src/welcome.rs2
18 files changed, 30 insertions, 201 deletions
diff --git a/src/clients/cheatsh.rs b/src/clients/cheatsh.rs
index 13ffaf7..fb29e8d 100644
--- a/src/clients/cheatsh.rs
+++ b/src/clients/cheatsh.rs
@@ -20,7 +20,7 @@ pub fn call(query: &str) -> Result<Vec<String>> {
let args = ["-qO-", &format!("cheat.sh/{}", query)];
let child = Command::new("wget")
- .args(&args)
+ .args(args)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn();
@@ -38,7 +38,7 @@ Make sure wget is correctly installed.";
if let Some(0) = out.status.code() {
let stdout = out.stdout;
- let plain_bytes = strip_ansi_escapes::strip(&stdout)?;
+ let plain_bytes = strip_ansi_escapes::strip(stdout)?;
let markdown = String::from_utf8(plain_bytes).context("Output is invalid utf8")?;
if markdown.starts_with("Unknown topic.") {
diff --git a/src/clients/tldr.rs b/src/clients/tldr.rs
index 81e827f..16ff216 100644
--- a/src/clients/tldr.rs
+++ b/src/clients/tldr.rs
@@ -55,7 +55,7 @@ pub fn call(query: &str) -> Result<Vec<String>> {
let args = [query, "--markdown"];
let child = Command::new("tldr")
- .args(&args)
+ .args(args)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
diff --git a/src/commands/core/actor.rs b/src/commands/core/actor.rs
index 6e1fd44..f356273 100644
--- a/src/commands/core/actor.rs
+++ b/src/commands/core/actor.rs
@@ -43,7 +43,7 @@ fn prompt_finder(
let child = shell::out()
.stdout(Stdio::piped())
- .arg(&suggestion_command)
+ .arg(suggestion_command)
.spawn()
.map_err(|e| ShellSpawnError::new(suggestion_command, e))?;
@@ -207,7 +207,7 @@ pub fn act(
env_var::set(env_var::PREVIEW_INITIAL_SNIPPET, &snippet);
env_var::set(env_var::PREVIEW_TAGS, &tags);
- env_var::set(env_var::PREVIEW_COMMENT, &comment);
+ env_var::set(env_var::PREVIEW_COMMENT, comment);
let interpolated_snippet = {
let mut s = replace_variables_from_snippet(
diff --git a/src/commands/func/widget.rs b/src/commands/func/widget.rs
index ff74d74..fc15c80 100644
--- a/src/commands/func/widget.rs
+++ b/src/commands/func/widget.rs
@@ -30,8 +30,8 @@ pub fn last_command() -> Result<()> {
}
for (pattern, escaped) in replacements.clone() {
- text = text.replace(&escaped, pattern);
- extracted = extracted.replace(&escaped, pattern);
+ text = text.replace(escaped, pattern);
+ extracted = extracted.replace(escaped, pattern);
}
println!("{}", extracted.trim_start());
diff --git a/src/commands/preview/var.rs b/src/commands/preview/var.rs
index 14880bf..4cf773e 100644
--- a/src/commands/preview/var.rs
+++ b/src/commands/preview/var.rs
@@ -94,7 +94,7 @@ impl Runnable for Input {
value
} else if is_current {
finder::process(value, column, delimiter.as_deref(), map.clone())
- .expect("Unable to process value")
+ .expect("Unable to process value")
} else {
"".to_string()
}
diff --git a/src/commands/repo/browse.rs b/src/commands/repo/browse.rs
index 2540772..f14cd16 100644
--- a/src/commands/repo/browse.rs
+++ b/src/commands/repo/browse.rs
@@ -29,7 +29,7 @@ pub fn main() -> Result<String> {
p
};
- let repos = fs::read_to_string(&feature_repos_file).context("Unable to fetch featured repositories")?;
+ let repos = fs::read_to_string(feature_repos_file).context("Unable to fetch featured repositories")?;
let opts = FinderOpts {
column: Some(1),
diff --git a/src/common/component.rs.bkp b/src/common/component.rs.bkp
deleted file mode 100644
index 4ffa9d5..0000000
--- a/src/common/component.rs.bkp
+++ /dev/null
@@ -1,21 +0,0 @@
-use super::prelude::*;
-
-pub trait Component: Any + AsAny + Send + Sync {}
-
-pub trait AsAny: Any {
- fn as_any(&self) -> &dyn Any;
- fn as_mut_any(&mut self) -> &mut dyn Any;
-}
-
-impl<T> AsAny for T
-where
- T: Any,
-{
- fn as_any(&self) -> &dyn Any {
- self
- }
-
- fn as_mut_any(&mut self) -> &mut dyn Any {
- self
- }
-}
diff --git a/src/common/deps.rs.bkp b/src/common/deps.rs.bkp
deleted file mode 100644
index e9624fc..0000000
--- a/src/common/deps.rs.bkp
+++ /dev/null
@@ -1,7 +0,0 @@
-use super::prelude::*;
-
-pub trait HasDeps {
- fn deps(&self) -> HashSet<TypeId> {
- HashSet::new()
- }
-}
diff --git a/src/common/deser.rs.bkp b/src/common/deser.rs.bkp
deleted file mode 100644
index 37d69b6..0000000
--- a/src/common/deser.rs.bkp
+++ /dev/null
@@ -1,50 +0,0 @@
-use super::prelude::*;
-use serde::de::DeserializeOwned;
-
-#[cfg(feature = "yaml")]
-pub fn yaml_from_path<T>(path: &Path) -> Result<T>
-where
- T: DeserializeOwned,
-{
- let file = File::open(path)?;
- let reader = BufReader::new(file);
- let config: T = serde_yaml::from_reader(reader)?; // TODO: show path + original error message?
- Ok(config)
-}
-
-#[cfg(feature = "json")]
-pub fn json_from_path<T>(path: &Path) -> Result<T>
-where
- T: DeserializeOwned,
-{
- let file = File::open(path)?;
- let reader = BufReader::new(file);
- let config: T = serde_json::from_reader(reader)?; // TODO: show path + original error message?
- Ok(config)
-}
-
-#[cfg(feature = "yaml")]
-pub fn yaml_from_str<T>(text: &str) -> Result<T>
-where
- T: DeserializeOwned,
-{
- serde_yaml::from_str(text)
- .with_context(|| format!("Failed to deserialize into yaml:\n{}", text))
-}
-
-#[cfg(feature = "json")]
-pub fn json_from_str<T>(text: &str) -> Result<T>
-where
- T: DeserializeOwned,
-{
- serde_json::from_str(text)
- .with_context(|| format!("Failed to deserialize into json:\n{}", text))
-}
-
-#[cfg(feature = "yaml")]
-pub fn to_yaml_str<T>(t: &T) -> Result<String>
-where
- T: Serialize,
-{
- serde_yaml::to_string(t).with_context(|| "Failed to serialize into yaml") // TODO: debug struct?
-}
diff --git a/src/common/git.rs b/src/common/git.rs
index 6c41692..9024613 100644
--- a/src/common/git.rs
+++ b/src/common/git.rs
@@ -4,7 +4,7 @@ use std::process::Command;
pub fn shallow_clone(uri: &str, target: &str) -> Result<()> {
Command::new("git")
- .args(&["clone", uri, target, "--depth", "1"])
+ .args(["clone", uri, target, "--depth", "1"])
.spawn()
.map_err(|e| ShellSpawnError::new("git clone", e))?
.wait()
diff --git a/src/common/shell.rs b/src/common/shell.rs
index dbb0a04..331eb32 100644
--- a/src/common/shell.rs
+++ b/src/common/shell.rs
@@ -38,7 +38,7 @@ pub fn out() -> Command {
let mut words_vec = shellwords::split(&words_str).expect("empty shell command");
let mut words = words_vec.iter_mut();
let first_cmd = words.next().expect("absent shell binary");
- let mut cmd = Command::new(&first_cmd);
+ let mut cmd = Command::new(first_cmd);
cmd.args(words);
let dash_c = if words_str.contains("cmd.exe") { "/c" } else { "-c" };
cmd.arg(dash_c);
diff --git a/src/common/system.rs.bkp b/src/common/system.rs.bkp
deleted file mode 100644
index c0813fd..0000000
--- a/src/common/system.rs.bkp
+++ /dev/null
@@ -1,57 +0,0 @@
-use super::prelude::*;
-use std::collections::hash_map::Entry;
-
-pub struct System<C> {
- pub config: Arc<C>,
- components: HashMap<TypeId, Arc<dyn Component>>,
- type_ids: Option<HashSet<TypeId>>,
-}
-
-impl<C> System<C> {
- pub fn new(config: C) -> Result<Self> {
- Ok(System {
- config: Arc::new(config),
- components: HashMap::new(),
- type_ids: None,
- })
- }
-
- pub fn get<T>(&self) -> Result<&T>
- where
- T: Component,
- {
- let type_id = TypeId::of::<T>();
- let c = self.components.get(&type_id).unwrap();
- c.as_any().downcast_ref::<T>().context("invalid component")
- }
-
- pub fn set_type_ids(&mut self, type_ids: HashSet<TypeId>) {
- self.type_ids = Some(type_ids);
- }
-
- pub fn maybe_add<T: Component, F: FnOnce(&Self) -> Result<T>>(
- &mut self,
- type_id: &TypeId,
- f: F,
- ) -> Result<Option<Arc<T>>> {
- let should_init = self
- .type_ids
- .as_ref()
- .context("system has no typeIds")?
- .contains(type_id);
-
- if !should_init {
- Ok(None)
- } else {
- let component = f(self)?;
- let arc = Arc::new(component);
- let entry = self.components.entry(*type_id);
- if let Entry::Vacant(e) = entry {
- e.insert(arc.clone());
- Ok(Some(arc))
- } else {
- Err(anyhow!("typeId already included in component map"))
- }
- }
- }
-}
diff --git a/src/common/tracing.rs.bkp b/src/common/tracing.rs.bkp
deleted file mode 100644
index bf3f02c..0000000
--- a/src/common/tracing.rs.bkp
+++ /dev/null
@@ -1,36 +0,0 @@
-use std::env;
-
-use super::prelude::*;
-
-static RUST_LOG: &str = "RUST_LOG";
-
-#[derive(Deserialize, Serialize)]
-#[serde(deny_unknown_fields)]
-pub struct TracingConfig {
- pub time: bool,
- pub level: String,
-}
-
-pub fn init(config: Option<&TracingConfig>) {
- if let Some(tracing) = config {
- let level_is_set = match env::var(RUST_LOG) {
- Err(_) => false,
- Ok(v) => !v.is_empty(),
- };
-
- if !level_is_set {
- env::set_var(RUST_LOG, &tracing.level);
- }
-
- let t = tracing_subscriber::fmt();
- let res = if tracing.time {
- t.try_init()
- } else {
- t.without_time().try_init()
- };
-
- if let Err(e) = res {
- error!("unable to set tracing subscriber: {}", e);
- }
- }
-}
diff --git a/src/filesystem.rs b/src/filesystem.rs
index 95736d6..9dc9f4e 100644
--- a/src/filesystem.rs
+++ b/src/filesystem.rs
@@ -13,7 +13,7 @@ use std::path::MAIN_SEPARATOR;
use walkdir::WalkDir;
pub fn all_cheat_files(path: &Path) -> Vec<String> {
- WalkDir::new(&path)
+ WalkDir::new(path)
.follow_links(true)
.into_iter()
.filter_map(|e| e.ok())
@@ -91,7 +91,7 @@ fn interpolate_paths(paths: String) -> String {
let mut newtext = paths.to_string();
for capture in re.captures_iter(&paths) {
if let Some(c) = capture.get(0) {
- let varname = c.as_str().replace('$', "").replace('{', "").replace('}', "");
+ let varname = c.as_str().replace(['$', '{', '}'], "");
if let Ok(replacement) = &env_var::get(&varname) {
newtext = newtext
.replace(&format!("${}", varname), replacement)
diff --git a/src/finder/mod.rs b/src/finder/mod.rs
index 3381449..f0efa5b 100644
--- a/src/finder/mod.rs
+++ b/src/finder/mod.rs
@@ -56,7 +56,7 @@ impl FinderChoice {
Self::Skim => "sk",
};
- let mut command = Command::new(&finder_str);
+ let mut command = Command::new(finder_str);
let opts = finder_opts.clone();
let preview_height = match self {
@@ -70,7 +70,7 @@ impl FinderChoice {
""
};
- command.args(&[
+ command.args([
"--preview",
"",
"--preview-window",
@@ -97,48 +97,48 @@ impl FinderChoice {
}
SuggestionType::Disabled => {
if let Self::Fzf = self {
- command.args(&["--print-query", "--no-select-1"]);
+ command.args(["--print-query", "--no-select-1"]);
};
}
SuggestionType::SnippetSelection => {
- command.args(&["--expect", "ctrl-y,ctrl-o,enter"]);
+ command.args(["--expect", "ctrl-y,ctrl-o,enter"]);
}
SuggestionType::SingleRecommendation => {
- command.args(&["--print-query", "--expect", "tab,enter"]);
+ command.args(["--print-query", "--expect", "tab,enter"]);
}
_ => {}
}
if let Some(p) = opts.preview {
- command.args(&["--preview", &p]);
+ command.args(["--preview", &p]);
}
if let Some(q) = opts.query {
- command.args(&["--query", &q]);
+ command.args(["--query", &q]);
}
if let Some(f) = opts.filter {
- command.args(&["--filter", &f]);
+ command.args(["--filter", &f]);
}
if let Some(d) = opts.delimiter {
- command.args(&["--delimiter", &d]);
+ command.args(["--delimiter", &d]);
}
if let Some(h) = opts.header {
- command.args(&["--header", &h]);
+ command.args(["--header", &h]);
}
if let Some(p) = opts.prompt {
- command.args(&["--prompt", &p]);
+ command.args(["--prompt", &p]);
}
if let Some(pw) = opts.preview_window {
- command.args(&["--preview-window", &pw]);
+ command.args(["--preview-window", &pw]);
}
if opts.header_lines > 0 {
- command.args(&["--header-lines", format!("{}", opts.header_lines).as_str()]);
+ command.args(["--header-lines", format!("{}", opts.header_lines).as_str()]);
}
if let Some(o) = opts.overrides {
diff --git a/src/finder/post.rs b/src/finder/post.rs
index cbd2d5e..717b7a9 100644
--- a/src/finder/post.rs
+++ b/src/finder/post.rs
@@ -89,7 +89,7 @@ pub(super) fn parse_output_single(mut text: String, suggestion_type: SuggestionT
SuggestionType::SingleRecommendation => {
let lines: Vec<&str> = text.lines().collect();
- match (lines.get(0), lines.get(1), lines.get(2)) {
+ match (lines.first(), lines.get(1), lines.get(2)) {
(Some(one), Some(termination), Some(two))
if *termination == "enter" || termination.is_empty() =>
{
diff --git a/src/parser.rs b/src/parser.rs
index d059c12..9498ed4 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -257,7 +257,7 @@ impl<'a> Parser<'a> {
if !item.tags.is_empty() && !item.comment.is_empty() {}
// blank
if line.is_empty() {
- if !(&item.snippet).is_empty() {
+ if !item.snippet.is_empty() {
item.snippet.push_str(deser::LINE_SEPARATOR);
}
}
@@ -316,7 +316,7 @@ impl<'a> Parser<'a> {
}
// snippet
else {
- if !(&item.snippet).is_empty() {
+ if !item.snippet.is_empty() {
item.snippet.push_str(deser::LINE_SEPARATOR);
}
item.snippet.push_str(&line);
diff --git a/src/welcome.rs b/src/welcome.rs
index bf3e618..520f04f 100644
--- a/src/welcome.rs
+++ b/src/welcome.rs
@@ -4,7 +4,7 @@ use crate::structures::fetcher;
pub fn populate_cheatsheet(parser: &mut Parser) -> Result<()> {
let cheatsheet = include_str!("../docs/navi.cheat");
- let lines = cheatsheet.split('\n').into_iter().map(|s| Ok(s.to_string()));
+ let lines = cheatsheet.split('\n').map(|s| Ok(s.to_string()));
parser.read_lines(lines, "welcome", None)?;