diff --git a/bash_tealdeer b/bash_tealdeer index aadcc05..6ed44cd 100644 --- a/bash_tealdeer +++ b/bash_tealdeer @@ -6,7 +6,7 @@ _tealdeer() _init_completion || return case $prev in - -h|--help|-v|--version|-l|--list|-u|--update|-c|--clear-cache|-p|--pager|-m|--markdown|--show-paths|--seed-config|-q|--quiet) + -h|--help|-v|--version|-l|--list|-u|--update|-c|--clear-cache|-p|--pager|-r|--raw|--show-paths|--seed-config|-q|--quiet) return ;; -f|--render) diff --git a/docs/src/usage.txt b/docs/src/usage.txt index 695eda1..3f5f24a 100644 --- a/docs/src/usage.txt +++ b/docs/src/usage.txt @@ -18,7 +18,7 @@ OPTIONS: -u, --update Update the local cache -c, --clear-cache Clear the local cache -p, --pager Use a pager to page output - -m, --markdown Display the raw markdown instead of rendering it + -r, --raw Display the raw markdown instead of rendering it -q, --quiet Suppress informational messages --show-paths Show file and directory paths used by tealdeer --config-path Show config file path diff --git a/fish_tealdeer b/fish_tealdeer index 7f2c63f..cad6cc2 100644 --- a/fish_tealdeer +++ b/fish_tealdeer @@ -11,7 +11,7 @@ complete -c tldr -s o -l os -d 'Override the operating system.' -xa 'li complete -c tldr -s u -l update -d 'Update the local cache.' -f complete -c tldr -s c -l clear-cache -d 'Clear the local cache.' -f complete -c tldr -s p -l pager -d 'Use a pager to page output.' -f -complete -c tldr -s m -l markdown -d 'Display the raw markdown instead of rendering it.' -f +complete -c tldr -s r -l raw -d 'Display the raw markdown instead of rendering it.' -f complete -c tldr -s q -l quiet -d 'Suppress informational messages.' -f complete -c tldr -l show-paths -d 'Show file and directory paths used by tealdeer.' -f complete -c tldr -l seed-config -d 'Create a basic config.' -f diff --git a/src/main.rs b/src/main.rs index 92787de..15ccac5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -95,7 +95,11 @@ struct Args { pager: bool, /// Display the raw markdown instead of rendering it - #[clap(short = 'm', long = "markdown", requires = "command")] + #[clap(short = 'r', long = "--raw", requires = "command")] + raw: bool, + + /// Deprecated alias of `raw` + #[clap(long = "markdown", short = 'm', requires = "command", hidden = true)] markdown: bool, /// Suppress informational messages @@ -363,7 +367,17 @@ fn main() { init_log(); // Parse arguments - let args: Args = Args::parse(); + let args = { + let mut args = Args::parse(); + + // Handle renamed arguments + if args.markdown { + args.raw = true; + eprintln!("Warning: The -m / --markdown flag is deprecated, use -r / --raw instead"); + } + + args + }; // Show config file and path, pass through if args.config_path { @@ -425,7 +439,7 @@ fn main() { // If a local file was passed in, render it and exit if let Some(ref file) = args.render { let path = PageLookupResult::with_page(PathBuf::from(file)); - if let Err(msg) = print_page(&path, args.markdown, &config) { + if let Err(msg) = print_page(&path, args.raw, &config) { eprintln!("{}", msg); process::exit(1); } else { @@ -484,7 +498,7 @@ fn main() { &languages, config.directories.custom_pages_dir.as_deref(), ) { - if let Err(msg) = print_page(&page, args.markdown, &config) { + if let Err(msg) = print_page(&page, args.raw, &config) { eprintln!("{}", msg); process::exit(1); } diff --git a/tests/lib.rs b/tests/lib.rs index b6cdff2..6ff88d2 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -339,7 +339,7 @@ fn test_markdown_rendering() { let expected = include_str!("which-markdown.expected"); testenv .command() - .args(["-m", "which"]) + .args(["--raw", "which"]) .assert() .success() .stdout(diff(expected)); diff --git a/zsh_tealdeer b/zsh_tealdeer index 96e40f0..0674063 100644 --- a/zsh_tealdeer +++ b/zsh_tealdeer @@ -24,7 +24,7 @@ _tealdeer() { "($I -u --update)"{-u,--update}"[Update the local cache]" "($I -c --clear-cache)"{-c,--clear-cache}"[Clear the local cache]" "($I -p --pager)"{-p,--pager}"[Use a pager to page output]" - "($I -m --markdown)"{-m,--markdown}"[Display the raw markdown instead of rendering it]" + "($I -r --raw)"{-r,--raw}"[Display the raw markdown instead of rendering it]" "($I -q --quiet)"{-q,--quiet}"[Suppress informational messages]" "($I)--show-paths[Show file and directory paths used by tealdeer]" "($I)--seed-config[Create a basic config]"