-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Suggestion: shell-agnostic config files #173
Comments
Another alternative to this would be for config files to change to commands that are invoked that output the configuration to stdout, as the format json/cson/toml/yaml or whatever specific format we adopt. This would also allow people to write dynamic config files in whatever language they want. |
To summarise, existing These option 1: invoker#!/usr/bin/env dorothy-bash-env
export HELLO=world In which the option 2: manual json#!/usr/bin/env bash
printf '%s' '{"HELLO": "world"}' #!/usr/bin/env nu
# https://www.nushell.sh/book/types_of_data.html#records
# https://www.nushell.sh/commands/categories/filters.html
# https://www.nushell.sh/commands/docs/to_json.html
{HELLO: 'world'} | to json -r #!/usr/bin/env node
process.stdout.write(JSON.stringify({HELLO: 'world'})) Which would then be parsed by the config loading script. Personally I'm leaning to option 2. Tooling can be created to make json construction easier for non-json languages. Furthermore we can even have configuration commands in any language, not just login shells, such as the Node.js example above. The reason why we don't just support The limitation of Furthermore this change would allow more commands to be written in other languages, as any language would now be able to parse configuration files. The big downside of this approach is that it would destroy our ability to update these configuration files programatically, as we currently do with our |
Currently dorothy's config files are sourced into the shell calling them, and as most of the files that load config files are bash the config files must either be .sh or .bash
I'm thinking instead of sourcing configuration files, we could execute them, similar to what we do with setup-environment-commands
For instance, a bash config file could do:
And our helper command bash-env sources our sources/env.bash that dumps the commands to set the modified environment variables.
we'd just have to update our sources/config.* files to understand how to load these, and provide the (bash|zsh|fish|nu)-env commands.
This would also allow us to do json or toml config files.
The issue here however is that currently Dorothy can update fields within bash configuration files. If we properly endorse other formats, we'd need to move this updating ability into a proper command, and give it the intelligence to support any extension we support.
The text was updated successfully, but these errors were encountered: