Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xplshn committed Mar 2, 2024
1 parent b488a2e commit 5716d2c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 59 deletions.
Binary file modified bigdl
Binary file not shown.
111 changes: 54 additions & 57 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import (
"runtime"
)

var Repositories []string
var MetadataURLs []string
var validatedArch = [3]string{}
var InstallDir = os.Getenv("INSTALL_DIR")
var (
Repositories []string
MetadataURLs []string
validatedArch = [3]string{}
InstallDir = os.Getenv("INSTALL_DIR")
installUseCache = true
useProgressBar = true
)

func init() {
if InstallDir == "" {
Expand Down Expand Up @@ -45,17 +49,11 @@ func init() {
MetadataURLs = append(MetadataURLs, "https://api.github.com/repos/xplshn/Handyscripts/contents")
}

var installUseCache = true
var useProgressBar = true

const RMetadataURL = "https://raw.githubusercontent.com/Azathothas/Toolpacks/main/metadata.json"
const RNMetadataURL = "https://bin.ajam.dev/METADATA.json"
const VERSION = "1.3"
const usagePage = "Usage: bigdl [-vh] {list|install|remove|update|run|info|search|tldr} [args...]"

///// YOU MAY CHANGE THESE TO POINT TO ANOTHER PLACE.

const (
RMetadataURL = "https://raw.githubusercontent.com/Azathothas/Toolpacks/main/metadata.json"
RNMetadataURL = "https://bin.ajam.dev/METADATA.json"
VERSION = "1.3.1"
usagePage = "Usage: bigdl [-vh] [list|install|remove|update|run|info|search|tldr] <args>"
// Truncation indicator
indicator = "...>"
// Cache size limit & handling.
Expand All @@ -65,29 +63,35 @@ const (
)

func printHelp() {
fmt.Printf("%s\n", usagePage)
fmt.Println("\nOptions:")
fmt.Println(" -h, --help Show this help message")
fmt.Println(" -v, --version Show the version number")
fmt.Println("\nCommands:")
fmt.Println(" list List all available binaries")
fmt.Println(" install, add Install a binary")
fmt.Println(" remove, del Remove a binary")
fmt.Println(" update Update binaries, by checking their SHA against the repo's SHA.")
fmt.Println(" run Run a binary")
fmt.Println(" info Show information about a specific binary")
fmt.Println(" search Search for a binary - (not all binaries have metadata. Use list to see all binaries)")
fmt.Println(" tldr Show a brief description & usage examples for a given program/command")
fmt.Println("\nExamples:")
fmt.Println(" bigdl install micro")
fmt.Println(" bigdl remove bed")
fmt.Println(" bigdl info jq")
fmt.Println(" bigdl search editor")
fmt.Println(" bigdl tldr gum")
fmt.Println(" bigdl run --verbose neofetch")
fmt.Println(" bigdl run --silent micro")
fmt.Println(" bigdl run btop")
fmt.Println("\nVersion:", VERSION)
helpMessage := usagePage + `
Options:
-h, --help Show this help message
-v, --version Show the version number
Commands:
list List all available binaries
install, add Install a binary
remove, del Remove a binary
update Update binaries, by checking their SHA against the repo's SHA.
run Run a binary
info Show information about a specific binary
search Search for a binary - (not all binaries have metadata. Use list to see all binaries)
tldr Show a brief description & usage examples for a given program/command
Examples:
bigdl install micro
bigdl remove bed
bigdl info jq
bigdl search editor
bigdl tldr gum
bigdl run --verbose neofetch
bigdl run --silent micro
bigdl run btop
Version: ` + VERSION

fmt.Println(helpMessage)
}

func main() {
Expand Down Expand Up @@ -127,7 +131,7 @@ func main() {
}
case "install", "add":
if len(os.Args) < 3 {
fmt.Printf("Usage: bigdl %s <binary> [install_dir] [install_message]\n", os.Args[1])
fmt.Printf("Usage: bigdl %s [binary] <install_dir> <install_message>\n", os.Args[1])
os.Exit(1)
}
binaryName := os.Args[2]
Expand All @@ -145,25 +149,25 @@ func main() {
}
case "remove", "del":
if len(os.Args) < 3 {
fmt.Printf("Usage: bigdl %s <binary>\n", os.Args[1])
fmt.Printf("Usage: bigdl %s [binary]\n", os.Args[1])
os.Exit(1)
}
remove(os.Args[2:])
case "run":
if len(os.Args) < 3 {
fmt.Println("Usage: bigdl run [--verbose, --silent] <binary> [args...]")
fmt.Println("Usage: bigdl run <--verbose, --silent> [binary] <args>")
os.Exit(1)
}
RunFromCache(os.Args[2], os.Args[3:])
case "tldr":
if len(os.Args) < 3 {
fmt.Println("Usage: bigdl tldr <page> [args...]")
fmt.Println("Usage: bigdl tldr <args> [page]")
os.Exit(1)
}
RunFromCache("tlrc", os.Args[2:])
case "info":
if len(os.Args) != 3 {
fmt.Println("Usage: bigdl info <binary>")
fmt.Println("Usage: bigdl info [binary]")
os.Exit(1)
}
binaryName := os.Args[2]
Expand All @@ -174,9 +178,7 @@ func main() {
}

// Print the fields
if binaryInfo.Name != "" {
fmt.Printf("Name: %s\n", binaryInfo.Name)
}
fmt.Printf("Name: %s\n", binaryInfo.Name)
if binaryInfo.Description != "" {
fmt.Printf("Description: %s\n", binaryInfo.Description)
}
Expand All @@ -197,25 +199,20 @@ func main() {
}
case "search":
if len(os.Args) != 3 {
fmt.Println("Usage: bigdl search <search-term>")
fmt.Println("Usage: bigdl search [query]")
os.Exit(1)
}
searchTerm := os.Args[2]
fSearch(searchTerm)
case "update":
var programsToUpdate []string
if len(os.Args) > 2 {
// Bulk update with list of programs to update
programsToUpdate := os.Args[2:]
if err := update(programsToUpdate); err != nil {
fmt.Printf("Error updating programs: %v\n", err)
os.Exit(1)
}
} else {
// Update by listing files from InstallDir
if err := update(nil); err != nil {
fmt.Printf("Error updating programs: %v\n", err)
os.Exit(1)
}
programsToUpdate = os.Args[2:]
}
if err := update(programsToUpdate); err != nil {
fmt.Printf("Error updating programs: %v\n", err)
os.Exit(1)
}
default:
fmt.Printf("bigdl: Unknown command: %s\n", os.Args[1])
Expand Down
2 changes: 1 addition & 1 deletion stubdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# TODO: put an IF to get AMD64 or arm64, OR return error

VERSION="1.3!"
VERSION="1.3.1"
BIGDL="https://github.com/xplshn/bigdl/releases/download/$VERSION/bigdl_amd64"
DEST="/tmp/._bdlstub_bigdl.bin"

Expand Down
2 changes: 1 addition & 1 deletion test_without_installing.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
curl -qfsL "https://github.com/xplshn/bigdl/releases/download/1.3!/bigdl_amd64" -o bigdl_amd64 && \
curl -qfsL "https://github.com/xplshn/bigdl/releases/download/1.3.1/bigdl_amd64" -o bigdl_amd64 && \
chmod +x bigdl_amd64 ; \
command -v ./bigdl_amd64 && \
./bigdl_amd64 run --silent gum confirm "Do you want to test $PWD/bigdl_amd64?" --negative="No, remove it!" || \
Expand Down
2 changes: 2 additions & 0 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"sync/atomic"
)

// TODO: Validation of programs could be done without a list (current bottleneck)

// update checks for updates to the valid programs and installs any that have changed.
func update(programsToUpdate []string) error {
// Initialize counters
Expand Down

0 comments on commit 5716d2c

Please sign in to comment.