Skip to content

Commit

Permalink
remove -c flag, it was confusing and not that useful
Browse files Browse the repository at this point in the history
  • Loading branch information
jreisinger committed May 13, 2023
1 parent 1410231 commit a8ec0b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 39 deletions.
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
# ghrel

`ghrel` lists, downloads and verifies assets (files) of the latest release from a GitHub repository:

```sh
$ ghrel -v -p '*linux*' -l jreisinger/ghrel
Asset Updated Size Download count
----- ------- ---- --------------
ghrel_0.8.0_linux_386.tar.gz 2023-04-12 2031657 7
ghrel_0.8.0_linux_amd64.tar.gz 2023-04-12 2144060 42
ghrel_0.8.0_linux_arm64.tar.gz 2023-04-12 1974168 8
ghrel_0.8.0_linux_armv6.tar.gz 2023-04-12 2008815 7
```
$ ghrel
Download and verify assets (files) of the latest release from a GitHub repository.
$ ghrel -v -p '*linux*' jreisinger/ghrel
downloaded 4 + 1 checksum file(s)
verified 4
removed checksum file(s)
ghrel [flags] <owner>/<repo>
-l just list assets, don't download them
-p pattern
assets matching shell pattern (doesn't apply to checksum files)
-v be verbose
```

To use ghrel, download a [binary](https://github.com/jreisinger/ghrel/releases) for your system and architecture or if you have [Go installed](https://go.dev/doc/install):

```sh
```
$ go install github.com/jreisinger/ghrel@latest
```
10 changes: 2 additions & 8 deletions asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,19 @@ func Download(a Asset) error {
}

// List prints a list of assets.
func List(assets []Asset, showChecksumFiles bool) {
func List(assets []Asset) {
for _, a := range assets {
if a.IsChecksumFile && !showChecksumFiles {
continue
}
fmt.Println(a.Name)
}
}

// ListTable prints a list of assets in a table format with additional info.
func ListTable(assets []Asset, showChecksumFiles bool) {
func ListTable(assets []Asset) {
const format = "%v\t%v\t%v\t%v\n"
tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0)
fmt.Fprintf(tw, format, "Asset", "Updated", "Size", "Download count")
fmt.Fprintf(tw, format, "-----", "-------", "----", "--------------")
for _, a := range assets {
if a.IsChecksumFile && !showChecksumFiles {
continue
}
fmt.Fprintf(tw, format, a.Name, a.UpdatedAt.Format("2006-01-02"), a.Size, a.DownloadCount)
}
tw.Flush()
Expand Down
18 changes: 2 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
)

var (
c = flag.Bool("c", false, "keep or list (-l) checksum files")
l = flag.Bool("l", false, "just list assets, don't download them")
p = flag.String("p", "", "assets matching shell `pattern` (doesn't apply to checksum files)")
v = flag.Bool("v", false, "be verbose")
Expand Down Expand Up @@ -44,9 +43,9 @@ func main() {

if *l {
if *v {
asset.ListTable(assets, *c)
asset.ListTable(assets)
} else {
asset.List(assets, *c)
asset.List(assets)
}
os.Exit(0)
}
Expand All @@ -73,19 +72,6 @@ func main() {
}
wg.Wait()

// Remove checksum files.
defer func() {
if !*c {
if err := removeChecksumFiles(assets); err != nil {
log.Print(err)
return
}
if *v {
fmt.Println("removed checksum file(s)")
}
}
}()

// Print download statistics.
if *v {
nFiles, nCheckumsFiles := asset.Count(assets)
Expand Down

0 comments on commit a8ec0b4

Please sign in to comment.