zyedidia / eget

Easily install prebuilt binaries from GitHub.
MIT License
866 stars 39 forks source link

Add downloading of configuration-defined projects #62

Closed patinthehat closed 1 year ago

patinthehat commented 1 year ago

Overview

This PR adds an additional flag, -D/--download-all, which adds new functionality:

When specifying the --download-all flag, all projects/repositories defined in the configuration file are downloaded in the order they exist within the config file.

If this flag is specified, no other parameters are required.

Implementation

This functionality was implemented by using exec.Command() to execute the currently running binary (which is an eget binary) sequentially for each of the configuration-defined repositories, and the output from the process is streamed in real time to the current stdout pipe by redirecting the process.stderr to the os.stderr.

This allows a complete implementation of batch downloading with a minimal amount of additional code, as it leverages eget functionality itself.

Example Usage

Given the following configuration file:

[global]
    github_token = ""
    quiet = false
    show_hash = true
    upgrade_only = true
    target = "./test"

["zyedidia/micro"]
    name = "micro"
    upgrade_only = false
    show_hash = false
    asset_filters = [ "static.tar.gz" ]

["zyedidia/eget"]
    name = "eget"
    upgrade_only = false
    show_hash = false
    asset_filters = [ ".tar.gz" ]

["junegunn/fzf"]
    name = "fzf"
    upgrade_only = false
    quiet = false

The following output is displayed when running eget --download-all: image

Notes

Original Notes: I'm not 100% sure that --download-config is the best name for this flag, so please suggest alternatives if anything comes to mind. I feel that it could be confusing if an end user thinks that the flag means a configuration file will be downloaded.

Alternatives could be --batch-download, --download-configured, or something similar. Thoughts?

Updated Notes: The flag has been renamed to --download-all per suggestion.

zyedidia commented 1 year ago

Cool thanks! I left some comments, and I think we should change the flag name to --download-all.

patinthehat commented 1 year ago

@zyedidia I've updated the flag name, which is much better than the original choice, thanks for the suggestion. Could you please re-review?

zyedidia commented 1 year ago

Thanks, I think there are still some changes to be made (see the review comments), and then I'll merge.

patinthehat commented 1 year ago

@zyedidia I've addressed all of the change requests - would you please re-review at your convenience? Thanks for all of the great suggestions to improve the code. :+1:

zyedidia commented 1 year ago

Looks good, thanks!