marler8997 / zigup

Download and manage zig compilers.
MIT No Attribution
793 stars 61 forks source link

Environment variables for configuration #91

Closed yohannd1 closed 1 year ago

yohannd1 commented 1 year ago

Hello! I've come to suggest support for two environment variables. Since these two vars always need to be passed as args and they don't change often, I think they would be good to have as a fallback.

# fallback for --install-dir
export ZIGUP_INSTALL_DIR=~/.cache/zigup

# fallback for --path-link
export ZIGUP_PATH_LINK=~/.local/bin/zig

# we don't need to specify them here!
zigup master

I suppose this can be done with a wrapper script, but I don't really see a reason not to add it, as (I think) it's a pretty standard thing to do. Also: I might be able to work on this, so expect a pull request soon :))

marler8997 commented 1 year ago

I took the time a while back to post about my thoughts on environment variables in the hopes that people would be more thoughtful when deciding when and when not to use them: https://github.com/ziglang/zig/issues/10754#issuecomment-1030439275

My opinion right now is that you should generally avoid using environment variables unless you NEED them. I don't know of any use cases that would require zigup to support these environment variables so my inclination is to not support them. Feel free to let me know of use cases this would enable that the command-line interface couldn't support.

yohannd1 commented 1 year ago

I understand, and I think that's a good argument. I'm just not sure what would be the best way to use the command casually, then. Would a config file at ~/.config/zigup.conf specifying the user's install and path link directories be a good idea?

marler8997 commented 1 year ago

By default most users won't need to override the default install/link paths. If you do need to there are currently 2 options. You can customize/build zigup yourself (the suckless method), or, you could wrap zigup in a script that provides the options. We can make the first option easier as well by making these build options. I think these options cover most if not all use cases?

yohannd1 commented 1 year ago

I believe so! I'll close this issue then, thanks.