mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-09 09:49:10 +02:00
Rename -m / --markdown to -r / --raw
That flag name is clearer: We output raw page data without processing.
This commit is contained in:
parent
ee0d32d3de
commit
8833b6b401
6 changed files with 23 additions and 9 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
22
src/main.rs
22
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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]"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue