Skip to content

Commit

Permalink
format usage linelength
Browse files Browse the repository at this point in the history
  • Loading branch information
JessThrysoee committed Feb 12, 2024
1 parent 215ed7e commit 0ea66c6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 34 deletions.
46 changes: 31 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,52 @@ A small container is provided for convenience of downloading release executables

# Usage

github-latest-release -r <OWNER/REPO> -l -p [REGEX_PATTERN]
github-latest-release -r <OWNER/REPO> -f -p <REGEX_PATTERN> -o [OUTPUT]
github-latest-release -r <OWNER/REPO> -t -p <REGEX_PATTERN>
github-latest-release -r <OWNER/REPO> -x -p <REGEX_PATTERN> -i [INCLUDE_GLOB_PATTERN] -s [STRIP_COMPONENTS] -c [DIRECTORY]
Usage:

github-latest-releast -r <OWNER/REPO> -l -p [REGEX]
github-latest-releast -r <OWNER/REPO> -f -p <REGEX> -o [OUTPUT]
github-latest-releast -r <OWNER/REPO> -t -p <REGEX>
github-latest-releast -r <OWNER/REPO> -x -p <REGEX> \
-i [INCLUDE_GLOB] -s [STRIP_COMPONENTS] -c [DIRECTORY]

Options:

-r <OWNER/REPO>
The mandatory github repo identifier, e.g. the 'owner/repo' part of 'https://github.com/owner/repo'
The github repo identifier. The 'owner/repo' part of 'https://github.com/owner/repo'

-l
List all available download urls. Use the '-p' regex pattern to identify a single download url.
List all available download urls. Use the '-p' regex pattern to identify a single
download url for use in the fetch commands.

Example: github-latest-release -r prometheus/prometheus -l -p 'linux-amd64.tar.gz$'
Example:
github-latest-releast -r prometheus/prometheus -l -p 'linux-amd64.tar.gz$'

-f
Fetch a release package. Use this if the release is a single executable or to download an archive.
Option '-o' is curl '-o'.
Fetch a release package. Use this if the release is a single executable or to
download an archive.

Options:
-o passthrough to curl --output

Example: github-latest-release -r 'tsl0922/ttyd' -f -p 'ttyd.mips64$' -o '/tmp/ttyd'
Example:
github-latest-releast -r 'tsl0922/ttyd' -f -p 'ttyd.mips64$' -o '/tmp/ttyd'

-t
Fetch and list files in archive.
Fetch and list files in archive.

Example: github-latest-release -r prometheus/prometheus -t -p 'linux-amd64.tar.gz$'
Example:
github-latest-releast -r prometheus/prometheus -t -p 'linux-amd64.tar.gz$'

-x
Fetch and extract from an archive.
Option '-i' is bsdtar '--include', '-s' is bsdtar '--strip-components', and '-c' is bsdar '-C'.
Fetch and extract from an archive.

Options:
-i passthrough to bsdtar --include
-s passthrough to bsdtar --strip-components
-c passthrough to bsdtar --cd

Example: github-latest-release -r prometheus/prometheus -x -p 'linux-amd64.tar.gz$' -i '*/prometheus' -s 1 -c /tmp
Example:
github-latest-releast -r prometheus/prometheus -x -p 'linux-amd64.tar.gz$' \
-i '*/prometheus' -s 1 -c /tmp


51 changes: 32 additions & 19 deletions github-latest-release
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# prerequisite: curl, jq, bsdtar
# prerequisite: curl, jq, bsdtar (libarchive-tools)

set -euo pipefail

Expand All @@ -19,7 +19,7 @@ select_download_url() {

if [[ -z $matches ]]; then
lines="0"
else
else
lines="$(wc -l <<< "$matches" | tr -d '[:blank:]')"
fi

Expand Down Expand Up @@ -60,41 +60,54 @@ extract_files() {
}

usage() {
local arg0="${0##*/}"
cat <<EOF
cat <<'EOF'
Usage:
$arg0 -r <OWNER/REPO> -l -p [REGEX_PATTERN]
$arg0 -r <OWNER/REPO> -f -p <REGEX_PATTERN> -o [OUTPUT]
$arg0 -r <OWNER/REPO> -t -p <REGEX_PATTERN>
$arg0 -r <OWNER/REPO> -x -p <REGEX_PATTERN> -i [INCLUDE_GLOB_PATTERN] -s [STRIP_COMPONENTS] -c [DIRECTORY]
github-latest-releast -r <OWNER/REPO> -l -p [REGEX]
github-latest-releast -r <OWNER/REPO> -f -p <REGEX> -o [OUTPUT]
github-latest-releast -r <OWNER/REPO> -t -p <REGEX>
github-latest-releast -r <OWNER/REPO> -x -p <REGEX> \
-i [INCLUDE_GLOB] -s [STRIP_COMPONENTS] -c [DIRECTORY]
Options:
-r <OWNER/REPO>
The mandatory github repo identifier, e.g. the 'owner/repo' part of 'https://github.com/owner/repo'
The github repo identifier. The 'owner/repo' part of 'https://github.com/owner/repo'
-l
List all available download urls. Use the '-p' regex pattern to identify a single download url.
List all available download urls. Use the '-p' regex pattern to identify a single
download url for use in the fetch commands.
Example: $arg0 -r prometheus/prometheus -l -p 'linux-amd64.tar.gz$'
Example:
github-latest-releast -r prometheus/prometheus -l -p 'linux-amd64.tar.gz$'
-f
Fetch a release package. Use this if the release is a single executable or to download an archive.
Option '-o' is curl '-o'.
Fetch a release package. Use this if the release is a single executable or to
download an archive.
Options:
-o passthrough to curl --output
Example: $arg0 -r 'tsl0922/ttyd' -f -p 'ttyd.mips64$' -o '/tmp/ttyd'
Example:
github-latest-releast -r 'tsl0922/ttyd' -f -p 'ttyd.mips64$' -o '/tmp/ttyd'
-t
Fetch and list files in archive.
Fetch and list files in archive.
Example: $arg0 -r prometheus/prometheus -t -p 'linux-amd64.tar.gz$'
Example:
github-latest-releast -r prometheus/prometheus -t -p 'linux-amd64.tar.gz$'
-x
Fetch and extract from an archive.
Option '-i' is bsdtar '--include', '-s' is bsdtar '--strip-components', and '-c' is bsdtar '-C'.
Fetch and extract from an archive.
Options:
-i passthrough to bsdtar --include
-s passthrough to bsdtar --strip-components
-c passthrough to bsdtar --cd
Example: $arg0 -r prometheus/prometheus -x -p 'linux-amd64.tar.gz$' -i '*/prometheus' -s 1 -c /tmp
Example:
github-latest-releast -r prometheus/prometheus -x -p 'linux-amd64.tar.gz$' \
-i '*/prometheus' -s 1 -c /tmp
EOF
}
Expand Down

0 comments on commit 0ea66c6

Please sign in to comment.