Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
1.6.9
Browse files Browse the repository at this point in the history
  • Loading branch information
xplshn committed Jul 8, 2024
1 parent 8bfcc8d commit 446d96f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
7 changes: 6 additions & 1 deletion findURL.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ func findURLCommand(binaryName string) {

// findURL fetches the URL for the specified binary.
func findURL(binaryName string) (string, error) {
iterations := 0
for _, Repository := range Repositories {
iterations++
url := fmt.Sprintf("%s%s", Repository, binaryName)
fmt.Printf("\033[2K\r<%d/%d> | Working: Checking if \"%s\" is in the repos.", iterations, len(Repositories), binaryName)
resp, err := http.Head(url)
if err != nil {
return "", err
}

if resp.StatusCode == http.StatusOK {
fmt.Printf("\033[2K\r<%d/%d> | Found \"%s\" at %s", iterations, len(Repositories), binaryName, Repository)
return url, nil
}
}

return "", fmt.Errorf("binary's SOURCE_URL was not found")
fmt.Printf("\033[2K\r")
return "", fmt.Errorf("Didn't find the SOURCE_URL for [%s]", binaryName)
}
5 changes: 4 additions & 1 deletion helperFunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func getTerminalWidth() int {
return 80
}

// NOTE: \n will always get cut off when using a truncate function, this may also happen to other formatting options
// truncateSprintf formats the string and truncates it if it exceeds the terminal width.
func truncateSprintf(format string, a ...interface{}) string {
// Format the string first
Expand All @@ -351,12 +352,14 @@ func truncateSprintf(format string, a ...interface{}) string {
return formatted
}

// NOTE: \n will always get cut off when using a truncate function, this may also happen to other formatting options
// truncatePrintf is a drop-in replacement for fmt.Printf that truncates the input string if it exceeds a certain length.
func truncatePrintf(format string, a ...interface{}) (n int, err error) {
if DisableTruncation {
return fmt.Printf(format, a...)
}
if AddNewLineToTruncateFn {
return fmt.Println(truncateSprintf(format, a...))
}
return fmt.Print(truncateSprintf(format, a...))
}

Expand Down
6 changes: 1 addition & 5 deletions listBinaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package main
import (
"fmt"
"path/filepath"
"sort"
"strings"
)

Expand Down Expand Up @@ -46,12 +45,9 @@ func listBinaries() ([]string, error) {
}
}

// Remove duplicates
// Remove duplicates based on their names
uniqueBinaries := removeDuplicates(filteredBinaries)

// Sort binaries alphabetically
sort.Strings(uniqueBinaries)

// Return the list of binaries
return uniqueBinaries, nil
}
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ var (
UseProgressBar = true
// DisableTruncation determines if update.go, fsearch.go, etc, truncate their messages or not
DisableTruncation = false
// Always adds a NEWLINE to text truncated by the truncateSprintf/truncatePrintf function
AddNewLineToTruncateFn = true
)

const (
VERSION = "1.6.8" // VERSION to be displayed
VERSION = "1.6.9" // VERSION to be displayed
usagePage = " [-v|-h] [list|install|remove|update|run|info|search|tldr] <-args->" // usagePage to be shown
// Truncation indicator
indicator = "...>"
Expand Down Expand Up @@ -63,9 +65,11 @@ var excludedFileNames = map[string]struct{}{
"TEST": {},
"LICENSE": {},
"experimentalBinaries_dir": {},
"bundles_dir": {},
"blobs_dir": {},
"robotstxt": {},
"bdl.sh": {},
// Because the repo contains duplicated files. And I do not manage the repo:
// Because the repo contains duplicated files. And I do not manage the repo nor plan to implement sha256 filtering :
"uroot": {},
"uroot-busybox": {},
"gobusybox": {},
Expand Down Expand Up @@ -93,6 +97,9 @@ func init() {
if os.Getenv("BIGDL_TRUNCATION") == "0" {
DisableTruncation = true
}
if os.Getenv("BIGDL_ADDNEWLINE") == "1" {
AddNewLineToTruncateFn = true
}
if os.Getenv("BIGDL_PRBAR") == "0" {
UseProgressBar = false
}
Expand Down Expand Up @@ -143,6 +150,7 @@ Commands:
Variables:
BIGDL_PRBAR If present, and set to ZERO (0), the download progressbar will be disabled
BIGDL_TRUNCATION If present, and set to ZERO (0), string truncation will be disabled
BIGDL_ADDNEWLINE If present, and set to ONE (1), truncated strings will always be on a new line
BIGDL_CACHEDIR If present, it must contain a valid directory
INSTALL_DIR If present, it must contain a valid directory
Expand Down
4 changes: 3 additions & 1 deletion update.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ func update(programsToUpdate []string) error {
}
// Print final counts
fmt.Println(finalCounts)
fmt.Print(errorMessages)
for error := range errorMessages {
fmt.Println(error)
}

return nil
}
Expand Down

0 comments on commit 446d96f

Please sign in to comment.