Open chshersh opened 1 year ago
Hi everyone,
I wanted to make sure we have the same variables name format in mind:
Currently, we have 2 different kinds of things we could configure - it's either store_directory\proxy (non tools related) or any tools field.
For non-tools related variables it's quite simple:
# ENV
TOOL_SYNC_STORE_DIRECTORY=~/.bin
# Cli
--store_directory=~/.bin
And for the tools it would be like:
# ENV
TOOL_SYNC_BOTTOM_OWNER=clementtsang
TOOL_SYNC_BOTTOM_REPO=bottom
TOOL_SYNC_BOTTOM_EXE_NAME=btm
TOOL_SYNC_ASSET_NAME_MACOS=darwin
# Cli
--bottom.owner=clementtsang
--bottom.repo=bottom
--bottom.exe_name=btm
--bottom.asset_name.macos=darwin
Do we want to use TOOL_SYNC
as the env prefix? I thought about just TOOL
, but it's quite ambiguous and could be reused by any other tool
(:
Do we really want to let the ENV
configure tools? It looks like parsing that would be a mess (still need to do it for the cli
though), and even with some generic parsing function the code will become more complicated.
@crudiedo Thanks for moving the conversation! Answering your question:
Do we want to use TOOL_SYNC as the env prefix? I thought about just TOOL, but it's quite ambiguous and could be reused by any other tool (:
I agree about the TOOL_SYNC_
prefix for environment variables 👍🏻
Do we really want to let the ENV configure tools? It looks like parsing that would be a mess (still need to do it for the cli though), and even with some generic parsing function the code will become more complicated.
No, we don't environment variables for individual tools 🙂 The usage for environment variables is to apply some configuration for every tool invocation and usually this is some global setting. Tool details are too granular and individual to be supported by env variables (and indeed will be a mess to parse as you mentioned).
My opinion:
Env:
CLI args:
File:
This pattern is common in the FP world. The description (in Haskell) can be found here:
The idea is the following:
Options
type with all configuration fields optional[ ] Create functions to create this
Options
type from different environments:It's absolutely okay for different environments to fill only some parts of the config.
Options
with the second argument overriding the previous values if they both are present (otherwise, take the one that is notNone
)That's all! With this approach, it should be possible to configure different options from different sources and have a uniform config.