Closed patinthehat closed 1 year ago
Wow, this is great! I think this is a really nice proposal for what the config file should support. I'll look at the code more in a bit, but my initial thought is that it would be nice to use a toml library directly (https://github.com/pelletier/go-toml), rather than depending on Viper, which seems to pull huge number of dependencies into go.sum, and generally seems a bit overkill. Thanks for the contribution!
@zyedidia Thanks! I put a lot of thought into the best way to configure eget
using a config file.
which seems to pull huge number of dependencies into go.sum, and generally seems a bit overkill.
The reason I chose viper was for a few reasons:
yaml
, json
, toml
, etc., if they prefer a specific formateget
to become a 12-factor app in the futureeget
to a new level of usefulnessI feel that viper gives us a lot of flexibility for the future. If you do decide that viper isn't what you want to use, I'll refactor and use the go-toml
library. Please Let me know.
@zyedidia Are there any changes you'd like to see to this PR for a merge?
I wanted to do pretty much the same thing that this pull request attempts to enable, but I handled it by putting together a simple shell-script wrapper that reads from a configuration file and drives multiple calls to eget
. You can see the script here. I've been using this to maintain a list of 40+ packages on a couple of different machines and it's been working great so far.
Sorry for the delay. I think it would be best to stick with a custom and simpler toml solution rather than using Viper and bringing in all the dependencies and complexity it has (850 additions to go.sum
is a bit concerning for a project of this size). In general I would like to err on the side of keeping eget small, though I think a config file of this sort would be useful and acceptable. Alternatively, maybe the eget-all script from @larsks provides enough functionality to cover your use-case?
@zyedidia I've refactored to use a smaller, toml-specific library. What do you think?
Great, thanks! Initially it looks good, will take a closer look shortly.
Looks great, thanks!
This PR adds support for using a configuration file with
Eget
.Summary
This adds supports for a TOML configuration file located at
~/.eget.toml
, or one located in the same directory as theeget
binary. Note that using command line flags will always override any configuration file settings that have been configured.Implementation
Both global settings can be configured, as well as setting on a per-repository basis.
Sections can be named either
global
or"owner/repo"
, whereowner
andrepo
are the owner and repository name of the target repository (not that theowner/repo
format is quoted).Sections can be named either
global
or"owner/repo"
, whereowner
andrepo
are the owner and repository name of the target repository (not that theowner/repo
format is quoted).For example, the following configuration file will set the
--to
flag to~/bin
for all repositories, and will set the--to
flag to~/.local/bin
for thezyedidia/micro
repository.Example configuration
By using the configuration above, you could run the following command to download the latest release of
micro
:Without the configuration, you would need to run the following command instead:
Available settings
github_token
N/A
""
all
--all
false
asset_filters
--asset
[]
download_only
--download-only
false
download_source
--source
false
file
--file
*
quiet
--quiet
false
show_hash
--sha256
false
system
--system
all
target
--to
.
upgrade_only
--upgrade-only
false