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

Change config subcommand into --config flag #290

Closed
lilyball opened this issue Apr 20, 2021 · 5 comments
Closed

Change config subcommand into --config flag #290

lilyball opened this issue Apr 20, 2021 · 5 comments

Comments

@lilyball
Copy link

I want to wrap zellij with a shell function that provides a default (non-standard) config path. Since Zellij currently uses a subcommand to change the config location, this means I can't wrap it without either breaking other commands or reimplementing my own parser for Zellij's complete set of args/flags. By making it a --config flag, that also implies that the presence of this flag does not change the action Zellij takes, it only defines where the config is found when it spawns a session. Which is to say, zellij --config path/to/config help should show the same output as zellij help. The equivalent to zellij config --clean could be zellij --config ''.

Additionally, if the user passes multiple --config flags, it would be nice if Zellij could simply ignore the earlier ones and use the last one passed. That way someone can still invoke my wrapper with a --config flag and it will take precedence.

My use-case here is wrapping Zellij with Nix, and putting the Zellij config into Nix as well.

An alternative to making this change is defining an env var that I can set that overrides the default config path. That way my wrapper can simply set that env var.

@a-kenji
Copy link
Contributor

a-kenji commented Apr 21, 2021

Thank you for the post!
I think the env var is a good idea in itself.
And also zellij using the last --config flag.
The reason config is a subcommand is that we don't just want
to support the --clean flag, but more flags in the future, but
we don't want to unneccesarrily break existing tools so that will get changed!
How does an option subcommand sound for the configurations? Or do you
maybe have more ideas?

@lilyball
Copy link
Author

From a usability perspective having this be a subcommand is also just weird. zellij invokes the tool. zellij config does the exact same thing. That's confusing. And it's also a problem if you ever want to add any other subcommands that actually care about the config file. It really makes the most sense to have the config file just be an option, which you can use to either change from the default (by passing a path) or have no config file (by passing an empty string, or having a separate flag if you prefer). And this option just says "if what you're doing with zellij involves reading a config file, change the file that's read".

I'm struggling to think of what else you might want to add to zellij config. The only thing that really comes to mind is a "validate" mode that means "don't start a session, just validate that the config is well-formed", but that could still be a subcommand in this new model (or a flag, but a subcommand seems more appropriate), like zellij validate-config --config path/to/config.

a-kenji added a commit to a-kenji/zellij that referenced this issue Apr 21, 2021
This changes the `config` subcommand to a config flag.

Add option subcommand for now, for the clearing of default path.

Add `ZELLIJ_CONFIG` environment variable.

The configuration locations are now as follows:
    * `--config` flag
    * `ZELLIJ_CONFIG` environment variable
    * default config location
in that order.
@a-kenji
Copy link
Contributor

a-kenji commented Apr 21, 2021

Yes, that makes a lot of sense.
Yes, something like just check the config, or dump different default configurations.
People have been asking for a configuration file that emulates a layout similar screen, or tmux.
We currently want to be able to output the default (and maybe the screen or tmux file) configuration to stdout.

@lilyball
Copy link
Author

Outputting the default configuration file could be a subcommand. But doing so would likely want to print it to stdout and thus wouldn't care about a path, and so isn't suitable for zellij config <path> anyway.

a-kenji added a commit that referenced this issue Apr 21, 2021
@a-kenji
Copy link
Contributor

a-kenji commented Apr 21, 2021

Thank you for the feedback!
I merged the change to the config flag and the env variable to the main branch.

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

No branches or pull requests

2 participants