summaryrefslogtreecommitdiff
path: root/src/subcommands
AgeCommit message (Collapse)Author
2025-07-15Fix clippy errors (#2016)Justin Su
2024-11-28Support external subcommands: rg, diff, git-show (etc.) (#1769)Thomas Otto
* Support external subcommands: rg, git show, git log (etc.) The possible command line now is: delta <delta-args> [SUBCMD <subcmd-args>] If the entire command line fails to parse because SUBCMD is unknown, then try (until the next arg fails) parsing <delta-args> only, and then parse and call SUBCMD.., its output is piped into delta. Other subcommands also take precedence over the diff/git-diff mode (`delta a b`, where e.g. a=git and b=show), and any diff call gets converted into an external subcommand first. Available are: delta rg .. => rg --json .. | delta delta a b .. => git diff a b .. | delta delta git show .. => git <color-on> show .. | delta and all other git-CMDS, of which add -p, blame, checkout -p, diff, grep, log -p, reflog -p, and stash show -p produce a diff. Because --json is automatically added for `delta rg ..`, it avoids the parsing ambiguities of and is easier to type than `rg .. | delta`. The piping is not done by the shell, but delta, so the subcommands are now child processes of delta. * Set calling process directly because delta started it This info then takes precedence over whatever start_determining_calling_process_in_thread() finds or rather doesn't find. (The simple yet generous SeqCst is used on purpose for the atomic operations.)
2024-11-29clippy 1.83: silence zombie_processes false positiveThomas Otto
But now < 1.83 clippy would complain about an unknown lint, so allow that, too.
2024-11-05Add optional capture-output writer to run_app()Thomas Otto
The output and exit code of run_app() are now testable, used for diff test.
2024-09-08Replace "light mode" bool with a dedicated enumTau Gärtli
2024-08-15Support passing arguments to git diff and diff (#1697)Dan Davison
Adds --diff-args with short form -@.
2024-08-01Wrap --help output and use pagerThomas Otto
Tell clap to not wrap output, append `after_long_help()` (with matching ansi codes in this section), then manually wrap the result. The help output is now paginated if writing to a terminal. All code paths flow back to main(), so an invoked pager is properly waited for (by the OutputType drop impl).
2024-08-01OutputType: PagerCfg and oneshot_writeThomas Otto
Use new, smaller PagerCfg instead of the full Config, as for pager output only 3 variables are relevant. oneshot_write() can be used to write paginated output, usually before exiting.
2024-06-24Don't read git files when --no-gitconfig is given + unused variables (#1728)Thomas Otto
* Fix unused variables * Don't read git files when --no-gitconfig is given Despite starting delta with `--no-gitconfig`, strace still shows that `.git/config` etc. files are accessed. By no longer doing that it is very clear that no config options are read from there.
2024-05-04Repair --default-language, and highlight using full filename (#1549)Thomas Otto
* Fix clippy warnings * Repair --default-language, and highlight using full filename Fixed that the "txt" fallback was used instead of --default-language And when looking for syntax highlighting, keep the filename around as long as possible. Using simple custom logic (filename > 4) a Makefile can be highlighted with make syntax, but a 'cc' or 'ini' file does not get treated like a *.cc or *.ini file. Currently the underlying highlighting lib syntect and the sublime syntax definitions can not make this distinction (<http://www.sublimetext.com/docs/syntax.html>).
2024-01-19--show-themes exit with error when no themes (#1611)Dan Davison
Fixes #587
2023-11-19feat: generate completion subcommand (#1561)plustik
* generate-completion subcommand * add Makefile target and replace completion scripts in repo with generated output * Add completion to manual
2023-07-08Replace usage of the `atty` crate with `std::io::IsTerminal` trait (#1465)nickelc
Rust 1.70 stabilized the `IsTerminal` trait and the newest version of `grep-cli` crate depending on it, makes it possible to remove the unmaintained `atty` crate from the build. ``` Crate: atty Version: 0.2.14 Warning: unsound Title: Potential unaligned read Date: 2021-07-04 ID: RUSTSEC-2021-0145 URL: https://rustsec.org/advisories/RUSTSEC-2021-0145 ```
2023-05-31Misc tab refactoring (#1424)Thomas Otto
* Move tabs logic into utils * Re-use buffer returned by tabs::expand * Add TabCfg to configure tabs Use the String from this config for the tab replacement. This avoids creating a new String for each processed line. * Avoid unicode segmentation for each line just to remove a prefix In some code paths no prefix is removed, and in almost all other cases the prefix is just ascii. This simplifies a lot of calls. * Set default tab with to 8 Editors like vim, emacs, nano and most terminal emulators set this value as the default tab display width.
2023-03-09Add methods for getting `GitConfig` as reference (#1336)nickelc
2023-03-01Fix the`--show-themes` command (#1320)nickelc
The command failed because the two empty arguments for the internal `Opt` parsing actually meant "<binary> <minus_file>" and since `minus_file` is now parsed with `PathBufValueParser` and the value parser rejects empty values.
2023-02-28Reduce allocations during `--show-colors` (#1315)nickelc
The colors are already sorted and can be returned as they are defined.
2023-02-28Fix clippy warnings (#1298)nickelc
* Fix clippy warnings - `clippy::uninlined_format_args` * Fix clippy warnings - `clippy::clone_on_copy` - `clippy::explicit_auto_deref` - `clippy::iter_cloned_collect` - `clippy::map_clone` - `clippy::needless_borrow` - `clippy::needless_lifetimes` - `clippy::needless_return` - `clippy::redundant_clone` - `clippy::redundant_field_names` - `clippy::seek_to_start_instead_of_rewind` - `clippy::unnecessary_cast` - `clippy::unused_unit`
2022-11-13Fix clippy warnings (#1236)clnoll
2022-03-30Add custom env struct to store env at init (#1025)William Escande
This allow to no longer ignore some tests (marked previously as FIXME) by storing the env at the start of the program (Or creating a custom env for test purpose) This centralize almost alls calls to std::env inside one wrapper Add a test profile to increase speed for testing (5min -> 20sec on my machine) clean a few code style like this: ``` if Some(value) = ... if value ``` to ``` if Some(true) = ... ``` Co-authored-by: William Escande <wescande@google.com>
2022-03-01Run in diff mode iff two positional arguments are suppliedDan Davison
Fixes #989
2022-02-27Use assets API from bat library instead of vendored code (#903)Dan Davison
Use assets API from bat library Fixes #895 Ref https://github.com/sharkdp/bat/issues/2026 Thanks @Enselic
2022-02-23Fall back to plain diff when process substitution is used (#978)Thomas Otto
When detecting input generated by `delta <(echo foo) <(echo bar)` fall back to plain `diff` instead of `git diff --no-index`. This does not respect various git settings anymore (the original reason to switch from `diff` to `git diff`), but is better than just showing the names of the temporary files.
2022-02-15Make git include colors in output going to delta (#966)Dan Davison
Fixes #965
2022-02-14Fix hyperlink absolute paths (#939)Dan Davison
Fix file paths and hyperlinks With this commit the target of a hyperlink should always be an absolute path. This should be true for all file hyperlinks, e.g. - File hyperlink - Hunk header hyperlink - Line number hyperlink Fixes #890
2022-01-25Update sysinfo version to 0.23Guillaume Gomez
2022-01-15structopt to clap (#889)Dan Davison
Replace structopt with clap Fixes #888 * Drop tests of deprecated options They were failing
2022-01-10Add diff-stat-align-width to show-configDan Davison
2021-12-09Store raw_line in HunkZero, as HunkMinus and HunkPlusDan Davison
ref #829
2021-12-07Move explain_ansi() part out of parse_ansi()Thomas Otto
2021-12-05Display merge conflictsDan Davison
2021-12-05Handle combined diff formatDan Davison
With this commit combined diff format (https://git-scm.com/docs/git-diff#_combined_diff_format) is handled appropriately. However, there is no special handling of merge conflict markers. Fixes #189, #736
2021-11-23Add --parse-ansi commandDan Davison
2021-11-22Navigate regexp (#782)Wayne Davison
* Allow navigate-regexp value to be overridden. * Don't add an empty label to the navigate_regexp. * Make --hunk-label=str not require --navigate. * Change navigate regexp to navigate regex. * Turn navigate-regex into an Option<String>.
2021-11-22Show colors subcommandDan Davison
Color groups from https://www.w3schools.com/colors/colors_groups.asp
2021-11-22Allow custom colors to be defined in gitconfig (#788)Dan Davison
Similar to 7a64fa5a26314c05c811d7c1276388a4963fa0bd which allowed custom styles. Custom styles must end in -style, but colors can be anything. It unfortunately seems not to be possible currently to store a global reference to git config, hence the size of this commit (passing the reference down the call stack).
2021-11-17Add the --right-arrow option.Wayne Davison
This allows the file1 -> file2 arrow to be configured to whatever characters the user desires. The default is the same unicode arrow as before with 2 spaces after it, since this allows someone to remove the extra spaces that are in the current output.
2021-11-15Refactor: utils moduleDan Davison
2021-11-15Handle `git blame` outputDan Davison
Fixes #426 Partial versions of these changes were previously in master and then reverted multiple times. See #746 0745f853d4bed52aca0b6739ac452d54ff54a153 3aab5d19569fa52ace2d7e6d196a1256990c4e20
2021-10-25Wrap linenumber configs in MinusPlus or LeftRightThomas Otto
2021-10-18Use fatal() to exit with errorcode 2 (#739)Thomas Otto
* Fix two typos * Dismantle two Pyramids of Doom Use question mark operator instead * Use fatal() to exit with errorcode 2
2021-10-16StructOpt without DefaultThomas Otto
This does not use the values provided by default_value, so validation will fail.
2021-09-19Option to set the background extension mode to ANSI or spacesThomas Otto
In side-by-side mode, if `background_color_extends_to_terminal_width` is set, the left panel color is extended via spaces, but the right one via an ANSI sequence which instructs the terminal emulator to fill the background color rightwards. The command line option --line-fill-method ansi|spaces can change how the right panel background is filled. Add enums `BgShouldFill` and `BgFillMethod` to better distinguish if the background should be filled, and if so, how.
2021-08-29Refactor: subcommands moduleDan Davison