-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: add --when.commands
scope
#5311
base: main
Are you sure you want to change the base?
Conversation
Unsure how to update Also unsure if / where there are tests for pagers. I was unable to find any on a cursory glance. |
I think it's better to not overuse [ui]
paginate = "auto" # default
pager = "..." # default
[<table-for-per-command-pager-options>]
status.paginate = "never"
diff.pager = ["delta", "..."]
# or generic per-command table like this?
[commands.status]
ui.paginate = "never"
# or extend the conditional table?
[[--scope]]
--when.commands = ["status"]
ui.paginate = "never"
I think "file show" and "file list" are quite different, and the user might want to enable pager only for one of them. |
I'm intrigued by extending the The rule for Currently, |
or
|
Just saw this, nice! 🎉 FYI, I'm planning to add config for the built-in pager. My original thought was to simply create a |
nit: might be better to include "streampager" in the key (e.g.
The current idea is to extend the scoped table, so any parameters (except for |
I went back and forth on this. I went into the direction of making the options more generic, see #5415 . Your suggestion might still be better, I'm not sure; it's easy to change. If we go with that, perhaps
That sounds great! |
f50ef2c
to
76b1269
Compare
--when.commands
scope
76b1269
to
dedbc47
Compare
Completely changed the implementation, as reflected in the title. Now implements Also changed how config resolution works --- a condition can either be "resolved true", "resolved false", or "unknown". If any field is "unknown", the entire expression is unknown, and kept around. If any field is "resolved false", the entire expression is false, and discarded. Otherwise, added to current config. This means that if a config layer still contains a |
Do we really need this? As I said, config layers are resolved multiple times in |
lib/src/config_resolver.rs
Outdated
let actual = actual.split(' '); | ||
let any_match = candidates.iter().any(|candidate| { | ||
let candidate = candidate.split(' '); | ||
candidate.zip_longest(actual.clone()).all(|e| match e { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe .strip_prefix()
and check the first character?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that is cleaner. Not sure why you would need to check the first character --- "file show".strip_prefix("file") == Some(" show")
, "file show".strip_prefix("file show") == Some("")
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the first character after stripping (i.e. the separator or end of string.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so jj abcdef
doesn't accidentally match --when.commands = ["abc"]
.
... oooh, the |
Motivating use case: [[--scope]] --when.command = ["log"] [--scope.ui] pager = "less" This adds a new (optional) field to `--when` config conditions, to inspect the current command. `--when.commands` is a list of space-separated values that matches a space-separated command. To be specific: --when.command = ["file"] # matches `jj file show`, `jj file list`, etc --when.command = ["file show"] # matches `jj file show`, but *NOT* `jj file list` --when.command = ["file", "log"] # matches `jj file` *OR* `jj log` (or subcommand of either) When both `--when.commands` and `--when.repositories` are set, the intersection is used.
dedbc47
to
6e9ec50
Compare
Closes #5217
Adds a new config scope resolution
--when.commands
. This is a list of space-separated commands:Checklist
If applicable:
CHANGELOG.md