From c7bb973e0ff0103b6197585c60563b596e5faf0a Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 27 Jun 2020 16:21:48 -0400 Subject: Rename --list-*, --show-* commands --list-syntax-themes => --show-syntax-themes --list-syntax-theme-names => --list-syntax-themes --show-styles => --show-config Fixes #207 Fixes #226 --- HomeBrewFormula/git-delta.rb | 2 +- README.v0.2.0.md | 8 ++++---- src/cli.rs | 25 +++++++++++++------------ src/config.rs | 8 -------- src/main.rs | 26 +++++++++++++++----------- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/HomeBrewFormula/git-delta.rb b/HomeBrewFormula/git-delta.rb index ffae7289..4ed29880 100644 --- a/HomeBrewFormula/git-delta.rb +++ b/HomeBrewFormula/git-delta.rb @@ -20,6 +20,6 @@ class GitDelta < Formula end test do - shell_output "#{bin}/delta --list-syntax-themes" + shell_output "#{bin}/delta --show-syntax-themes" end end diff --git a/README.v0.2.0.md b/README.v0.2.0.md index ef20bafd..837d80f4 100644 --- a/README.v0.2.0.md +++ b/README.v0.2.0.md @@ -388,10 +388,10 @@ FLAGS: combining this option with style options such as --minus-style, --zero-style, --plus-style, etc --list-languages List supported languages and associated file extensions - --list-syntax-theme-names List available syntax-highlighting color themes - --list-syntax-themes List available syntax-highlighting themes, each with an example of highlighted diff + --list-syntax-themes List available syntax-highlighting color themes + --show-syntax-themes List available syntax-highlighting themes, each with an example of highlighted diff output. If diff output is supplied on standard input then this will be used for the - demo. For example: `git show --color=always | delta --list-syntax-themes` + demo. For example: `git show --color=always | delta --show-syntax-themes` --highlight-removed Deprecated: use --minus-style='syntax' -h, --help Prints help information -V, --version Prints version information @@ -401,7 +401,7 @@ OPTIONS: Name of delta features to use (space-separated). A feature is a named collection of delta options in ~/.gitconfig. See FEATURES section [default: ] --syntax-theme - The code syntax-highlighting theme to use. Use --list-syntax-themes to demo available themes. If the syntax- + The code syntax-highlighting theme to use. Use --show-syntax-themes to demo available themes. If the syntax- highlighting theme is not set using this option, it will be taken from the BAT_THEME environment variable, if that contains a valid theme name. --syntax-theme=none disables all syntax highlighting [env: BAT_THEME=base16] diff --git a/src/cli.rs b/src/cli.rs index 01aa0fba..34c5716e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -208,7 +208,7 @@ pub struct Opt { pub features: String, #[structopt(long = "syntax-theme", env = "BAT_THEME")] - /// The code syntax-highlighting theme to use. Use --list-syntax-themes to demo available + /// The code syntax-highlighting theme to use. Use --show-syntax-themes to demo available /// themes. If the syntax-highlighting theme is not set using this option, it will be taken /// from the BAT_THEME environment variable, if that contains a valid theme name. /// --syntax-theme=none disables all syntax highlighting. @@ -384,26 +384,27 @@ pub struct Opt { #[structopt(long = "tabs", default_value = "4")] pub tab_width: usize, - /// Print the style strings for all style options. This can be used to experiment with - /// different colors by combining this option with other options such as --minus-style, - /// --zero-style, --plus-style, --light, --dark, etc. - #[structopt(long = "show-styles")] - pub show_styles: bool, + /// Display the active values for all Delta options. Style options are displayed with + /// foreground and background colors. This can be used to experiment with colors by combining + /// this option with other options such as --minus-style, --zero-style, --plus-style, --light, + /// --dark, etc. + #[structopt(long = "show-config")] + pub show_config: bool, /// List supported languages and associated file extensions. #[structopt(long = "list-languages")] pub list_languages: bool, /// List available syntax-highlighting color themes. - #[structopt(long = "list-syntax-theme-names")] - pub list_syntax_theme_names: bool, - - /// List available syntax-highlighting themes, each with an example of highlighted diff output. - /// If diff output is supplied on standard input then this will be used for the demo. For - /// example: `git show --color=always | delta --list-syntax-themes`. #[structopt(long = "list-syntax-themes")] pub list_syntax_themes: bool, + /// Show all available syntax-highlighting themes, each with an example of highlighted diff output. + /// If diff output is supplied on standard input then this will be used for the demo. For + /// example: `git show --color=always | delta --show-syntax-themes`. + #[structopt(long = "show-syntax-themes")] + pub show_syntax_themes: bool, + /// The regular expression used to decide what a word is for the within-line highlight /// algorithm. For less fine-grained matching than the default try --word-diff-regex="\S+" /// --max-line-distance=1.0 (this is more similar to `git --word-diff`). diff --git a/src/config.rs b/src/config.rs index 672a9507..03e0d68e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -34,9 +34,6 @@ pub struct Config { pub file_style: Style, pub keep_plus_minus_markers: bool, pub hunk_header_style: Style, - pub list_languages: bool, - pub list_syntax_theme_names: bool, - pub list_syntax_themes: bool, pub max_buffered_lines: usize, pub max_line_distance: f64, pub max_line_distance_for_naively_paired_lines: f64, @@ -61,7 +58,6 @@ pub struct Config { pub plus_file: Option, pub plus_non_emph_style: Style, pub plus_style: Style, - pub show_styles: bool, pub line_numbers: bool, pub syntax_dummy_theme: SyntaxTheme, pub syntax_set: SyntaxSet, @@ -198,9 +194,6 @@ impl From for Config { file_style, keep_plus_minus_markers: opt.keep_plus_minus_markers, hunk_header_style, - list_languages: opt.list_languages, - list_syntax_theme_names: opt.list_syntax_theme_names, - list_syntax_themes: opt.list_syntax_themes, max_buffered_lines: 32, max_line_distance: opt.max_line_distance, max_line_distance_for_naively_paired_lines, @@ -225,7 +218,6 @@ impl From for Config { plus_file: opt.plus_file.map(|s| s.clone()), plus_non_emph_style, plus_style, - show_styles: opt.show_styles, line_numbers: opt.line_numbers, syntax_dummy_theme, syntax_set: assets.syntax_set, diff --git a/src/main.rs b/src/main.rs index 26a383c5..92dce70a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,19 +51,23 @@ mod errors { fn main() -> std::io::Result<()> { let opt = cli::Opt::from_args_and_git_config(&mut git_config::GitConfig::try_create()); - let config = config::Config::from(opt); - if config.list_languages { + if opt.list_languages { list_languages()?; process::exit(0); - } else if config.list_syntax_theme_names { - list_syntax_theme_names()?; - process::exit(0); - } else if config.list_syntax_themes { + } else if opt.list_syntax_themes { list_syntax_themes()?; process::exit(0); - } else if config.show_styles { - show_styles(&config); + } else if opt.show_syntax_themes { + show_syntax_themes()?; + process::exit(0); + } + + let _show_config = opt.show_config; + let config = config::Config::from(opt); + + if _show_config { + show_config(&config); process::exit(0); } else if atty::is(atty::Stream::Stdin) { return diff( @@ -120,7 +124,7 @@ fn diff( Ok(()) } -fn show_styles(config: &config::Config) { +fn show_config(config: &config::Config) { print!( "\ commit-style = {commit_style} @@ -168,7 +172,7 @@ line-numbers-right-style = {line_numbers_right_style}", println!(); } -fn list_syntax_themes() -> std::io::Result<()> { +fn show_syntax_themes() -> std::io::Result<()> { use bytelines::ByteLines; use std::io::BufReader; let opt = cli::Opt::from_args(); @@ -237,7 +241,7 @@ index f38589a..0f1bb83 100644 Ok(()) } -pub fn list_syntax_theme_names() -> std::io::Result<()> { +pub fn list_syntax_themes() -> std::io::Result<()> { let assets = HighlightingAssets::new(); let themes = &assets.theme_set.themes; let stdout = io::stdout(); -- cgit v1.2.3