mirror of
https://github.com/denisidoro/navi
synced 2024-11-21 19:13:07 +00:00
Merge pull request #873 from cyhyraethz/master
fix: #845 Add config option to support tealdeer
This commit is contained in:
commit
c45b767edd
4 changed files with 32 additions and 6 deletions
|
@ -27,6 +27,9 @@ finder:
|
||||||
# search:
|
# search:
|
||||||
# tags: git,!checkout # equivalent to the --tag-rules option
|
# tags: git,!checkout # equivalent to the --tag-rules option
|
||||||
|
|
||||||
|
# client:
|
||||||
|
# tealdeer: true # enables tealdeer support for navi --tldr
|
||||||
|
|
||||||
shell:
|
shell:
|
||||||
# Shell used for shell out. Possible values: bash, zsh, dash, ...
|
# Shell used for shell out. Possible values: bash, zsh, dash, ...
|
||||||
# For Windows, use `cmd.exe` instead.
|
# For Windows, use `cmd.exe` instead.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use crate::config::CONFIG;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
@ -51,7 +52,9 @@ fn markdown_lines(query: &str, markdown: &str) -> Vec<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn call(query: &str) -> Result<Vec<String>> {
|
pub fn call(query: &str) -> Result<Vec<String>> {
|
||||||
let args = [query, "--markdown"];
|
let tealdeer = CONFIG.tealdeer();
|
||||||
|
let output_flag = if tealdeer { "--raw" } else { "--markdown" };
|
||||||
|
let args = [query, output_flag];
|
||||||
|
|
||||||
let child = Command::new("tldr")
|
let child = Command::new("tldr")
|
||||||
.args(args)
|
.args(args)
|
||||||
|
@ -96,6 +99,7 @@ Error:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
The client.tealdeer config option can be set to enable tealdeer support.
|
||||||
Please make sure you're using a version that supports the --markdown flag.
|
Please make sure you're using a version that supports the --markdown flag.
|
||||||
If you are already using a supported version you can ignore this message.
|
If you are already using a supported version you can ignore this message.
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -99,6 +99,10 @@ impl Config {
|
||||||
.or_else(|| self.yaml.finder.overrides_var.clone())
|
.or_else(|| self.yaml.finder.overrides_var.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn tealdeer(&self) -> bool {
|
||||||
|
self.yaml.client.tealdeer.clone()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn shell(&self) -> String {
|
pub fn shell(&self) -> String {
|
||||||
self.yaml.shell.command.clone()
|
self.yaml.shell.command.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,12 @@ pub struct Shell {
|
||||||
pub finder_command: Option<String>,
|
pub finder_command: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct Client {
|
||||||
|
pub tealdeer: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug)]
|
#[derive(Deserialize, Default, Debug)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct YamlConfig {
|
pub struct YamlConfig {
|
||||||
|
@ -86,6 +92,7 @@ pub struct YamlConfig {
|
||||||
pub cheats: Cheats,
|
pub cheats: Cheats,
|
||||||
pub search: Search,
|
pub search: Search,
|
||||||
pub shell: Shell,
|
pub shell: Shell,
|
||||||
|
pub client: Client,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl YamlConfig {
|
impl YamlConfig {
|
||||||
|
@ -162,3 +169,11 @@ impl Default for Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Client {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
tealdeer: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue