Skip to content
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

Add command to check config values #5972

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rstefanic
Copy link

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.

wezterm ls-config --setting font_size
# "font_size" = 16.0

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 the Config into a dynamic Value in order to iterate through it. While converting the Config into a dynamic is probably not the most performant thing, the advantage to this approach is that any future changes made to Config will automatically be reflected in this feature. Since this Config 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 subcommand ls-config since it seemed similar to ls-fonts. In the same vein, I added the implementation in wezterm-gui simply because that's where ls-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!

This commit adds a `ls-config` subcommand to list the current
configuration values. If no options are passed in, then the entire
config will be printed to the screen. The subcommand has one optional
argument of `setting` to print a single config value.
@mattmc3
Copy link

mattmc3 commented Aug 18, 2024

See also - there's a method via the debugger described here: #4238 (comment)

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