https://github.com/yaonyan/ghdl
A much more convenient way to download GitHub release binaries on the command line, works on Win & Unix-like systems
https://github.com/yaonyan/ghdl
binary executable github-release
Last synced: 10 months ago
JSON representation
A much more convenient way to download GitHub release binaries on the command line, works on Win & Unix-like systems
- Host: GitHub
- URL: https://github.com/yaonyan/ghdl
- Owner: beetcb
- License: mit
- Created: 2022-02-08T05:30:39.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-05T03:49:47.000Z (over 2 years ago)
- Last Synced: 2024-08-04T01:10:13.558Z (over 1 year ago)
- Topics: binary, executable, github-release
- Language: Go
- Homepage:
- Size: 3.43 MB
- Stars: 52
- Watchers: 1
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ghdl
> Memorize `ghdl` as `github download`
`ghdl` is a fast and simple program (and also a golang module) for downloading and installing executable binary from github releases.
The demo above extracts fd execuable to current working directory and give execute permission to it.
# Features
- Auto decompressing and unarchiving the downloaded asset (without any system dependencies like `tar` or `unzip`)
```ts
Currently supporting unarchiving `tar` and decompressing `zip` `gzip`.
Package format `deb` `rpm` `apk` will be downloaded directly
```
`ghdl` binary is statically linked, works well on non-FHS *nix systems like [NixOS](https://nixos.org/)). In case this is relevant to you, on that kind of system, only binaries like `ghdl` can be run directly.
- Setups for executable: `ghdl` moves executable to specified location and add execute permissions to the file.
- Auto filtering: multiple assets in one release will be filtered by OS or ARCH. This feature can be disabled using `-F` flag.
- Interactive TUI: when auto filtering is failed or returned multiple options, you can select assets in a interactive way, with vim key bindings support.
- Release tags: `ghdl` downloads latest release by default, other or old tagged releases can be downloaded by specifying release tag: `username/repo#tagname`
- Inspect download status with real-time progress bar.
# Installation
> If you're going to use `ghdl` as a go module, ignore the following installation progress.
- Using Go tools:
go will download the latest version of ghdl to $GOPATH/bin, please make sure $GOPATH is in the PATH:
```sh
go install github.com/beetcb/ghdl/ghdl@latest
```
> Note: Just to be safe, you'd better specify CGO_ENABLED=0 when running `go install` on non-FHS *nix systems like [NixOS](https://nixos.org/))
- Download and run executable from release.
- Run the following shell script(*nix system only):
```sh
curl -fsSL "https://bina.egoist.sh/beetcb/ghdl?dir=/usr/local/bin" | sh
# feel free to change the `dir` url param to specify the installation directory.
```
# Usage
### CLI
Run `ghdl --help`
```sh
❯ ghdl --help
ghdl download binary from github release
ghdl handles archived or compressed file as well
Usage:
ghdl [flags]
Flags:
-f, --asset-filter string specify regular expression for the asset name; used in conjunction with the platform and architecture filters.
-F, --filter-off turn off auto-filtering feature
-h, --help help for ghdl
-n, --name string specify binary file name to enhance filtering and extracting accuracy
-p, --path path save binary to path and add execute permission to it (default ".")
```
It's tedious to specify `-p` manually, we can alias `ghdl -p "$DirInPath"` to a shorthand command, then use it as a executable installer.
### Go Module
1. Require `ghdl` to go.mod
```sh
go get github.com/beetcb/ghdl
```
2. Use `ghdl`'s out-of-box utilities: see [TestDownloadFdBinary func](./ghdl_test.go) as an example
# Credit
Inspired by [egoist/bina](https://github.com/egoist/bina), TUI powered by [charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea)
# License
Licensed under [MIT](./LICENSE)
Author: @beetcb | Email: i@beetcb.com