chshersh / tool-sync

🧰 Download pre-built binaries of all your favourite tools with a single command
https://crates.io/crates/tool-sync
Mozilla Public License 2.0
72 stars 17 forks source link

[RFC] CLI for config related commands #75

Closed chshersh closed 2 years ago

chshersh commented 2 years ago

Blocking #72

tool-sync works with the config and it's desirable to have multiple features around easy work with the config. Currently, tool-sync has a single command default-config to print the default configuration to stdout and the --config option to specify the path to the config.

This feels a bit awkward so I'd like to start an RFC about a better design of config-related CLI commands.

This RFC talks not only about existing features (at this point we don't have many of them) but also about potential future features.

[current] Option 1: default-config

The idea is to prefix all commands with the default- string and use different options:

Pros

✅ Already implemented (default-config) ✅ Has no conflicts with the global --config

Cons

⛔ Not extensible to non-default commands ⛔ More complicated interaction with the global --config option: See discussion:

[proposed] Option 2: config --bla

An alternative option is to introduce a new config command and make the --config flag local to other commands (so there's no tool --config=... config command). The behaviour:

Pros

✅ Single entry-point for all config-related commands (covers both default and non-default options)

Cons

⛔ Can be confused with the global --config flag: requires making this flag local to the subcommand (breaking change) ⛔ Requires changes and duplication of the `--config

Other ideas?

If you have any thoughts, please, feel free to share your feedback!

I'll leave the current behaviour (Option 1) as it is for now until we get more information on how to improve config-related options and what features are desirable.

MitchellBerend commented 2 years ago

I personally like having the global --config flag. It does not make sense for the default-config sub command but I can see it being useful for most other sub commands. If this program gets expands functionality I assume all config options will be put in the .tools.config.

Having the ability to check in the .tools.tomlinto a a separate git repo would also play nice with tools like ansible/salt-stack. Thats the way I personally use it.


[Feature] Another option could also be adding an environment variable where the config is stored. This could be added as a way to set the config path besides the --config flag

Pros

Cons

chshersh commented 2 years ago

I propose to keep the default-config command and implement the --path option for it.

The truth is, I'm not sure that we'll want to add more complications to the config commands just to support something that is easier to do by simply editing the config. So I don't think we'll have the set-config or other commands.

Another sanity check: it's not even clear what tool config on its own should actually do. It doesn't make sense and it's too generic. So let's keep Option 1 and I'll create followup issues.