Add command to check config values #5972
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First off, thanks for wezterm. I just started using it this week and it's fantastic!
While getting setup with wezterm, I tried to see if there's a way to check an existing config value and I came across issue #4238. I wasn't sure if you wanted to add a feature like this, but I took a crack at it.
This PR adds a new
ls-config
subcommand to list configuration values. If no options are passed in, it will list all the configuration values. The--setting
flag can be passed with the name of a config to show its current value.Implementation wise, I figured that, since the config came in as a Lua table, I should be able to iterate over it like a Lua table. I came across the
ToDynamic
trait in the project and used it to convert theConfig
into a dynamicValue
in order to iterate through it. While converting theConfig
into a dynamic is probably not the most performant thing, the advantage to this approach is that any future changes made toConfig
will automatically be reflected in this feature. Since thisConfig
conversion only occurs once and then the program exits, I figured it would be alright.An alternative approach I came up with was to create a lookup table with all the possible config values mapped to the
Config
struct but I figured that having to maintain a separate lookup table like that would be a burden.As a side note, the issue referenced above suggested using something like
wezterm --config
but I didn’t want to conflict with the existing flag to override a specific configuration value. I named the subcommandls-config
since it seemed similar tols-fonts
. In the same vein, I added the implementation inwezterm-gui
simply because that's wherels-fonts
was implemented. Let me know if they belong somewhere else or if the subcommand needs to be renamed.If this is not a feature that you want to add, then feel free to close this this PR. Thanks again for wezterm. I'm loving it!