Skip to content

Add --no-* negation flags for boolean CLI options#2095

Open
pablospe wants to merge 5 commits into
dandavison:mainfrom
pablospe:no-flags
Open

Add --no-* negation flags for boolean CLI options#2095
pablospe wants to merge 5 commits into
dandavison:mainfrom
pablospe:no-flags

Conversation

@pablospe
Copy link
Copy Markdown
Contributor

@pablospe pablospe commented Feb 1, 2026

Summary

  • Add hidden --no-* counterparts for 10 boolean flags: --no-side-by-side, --no-line-numbers, --no-navigate, --no-hyperlinks, --no-color-only, --no-diff-highlight,
    --no-diff-so-fancy, --no-keep-plus-minus-markers, --no-raw, --no-relative-paths
  • Allows disabling boolean options from the CLI when they are enabled in gitconfig
  • Uses clap's overrides_with for last-flag-wins semantics (e.g. --side-by-side --no-side-by-side → disabled)

Motivation

When boolean flags like --side-by-side or --line-numbers are set in gitconfig, there is currently no CLI way to disable them. This is needed for tools that invoke delta programmatically and need to toggle features on and off.

Note: this is a workaround until clap-rs/clap#815 is resolved, which would allow clap to natively support --no-* flag generation.

Allow disabling boolean flags (e.g. --side-by-side, --line-numbers,
--navigate) from the command line when they are enabled in gitconfig.

Uses clap's overrides_with for last-flag-wins semantics, so
`--side-by-side --no-side-by-side` disables and vice versa.

Flags added: --no-color-only, --no-diff-highlight, --no-diff-so-fancy,
--no-hyperlinks, --no-keep-plus-minus-markers, --no-line-numbers,
--no-navigate, --no-raw, --no-relative-paths, --no-side-by-side
Test that --no-* flags override gitconfig values and that last-flag-wins
semantics work correctly.
Use if-let destructuring instead of is_some() + unwrap().
Keep tuple destructuring approach for width/alignment_spec
to avoid unnecessary unwrap().
@pablospe
Copy link
Copy Markdown
Contributor Author

@dandavison Ready for review. Thanks

@dandavison
Copy link
Copy Markdown
Owner

Hi @pablospe, how confident are you that the command names here will match exactly what clap introduces, if they do introduce a solution?

@pablospe
Copy link
Copy Markdown
Contributor Author

That's a fair concern. I'm not fully confident the names would match exactly. However, the upstream issue (clap-rs/clap#815) has been open since 2017 and there doesn't seem to be movement toward a built-in solution anytime soon.

Given how straightforward this implementation is and that it addresses a real usability need (being able to override config file settings from the command line), I think it's worth having now rather than waiting indefinitely. If clap ever does add native support, it should be easy to migrate at that point.

@pablospe
Copy link
Copy Markdown
Contributor Author

@dandavison. Following up on your question about clap compatibility. I went with the --no-* convention which is the most common pattern for flag negation.

Would you prefer a different approach here? For example:

  • A different naming convention (e.g. --disable-*)
  • Restricting this to just a few high-demand flags like --no-side-by-side
  • Waiting for clap's native solution

Let me know what you'd like and I'll update the PR accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants