-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
setup-util-ripgrep
executable file
·101 lines (93 loc) · 2.94 KB
/
setup-util-ripgrep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
# https://github.com/BurntSushi/ripgrep
# https://github.com/BurntSushi/ripgrep/issues/1094
# grep alternative
# https://github.com/BurntSushi/ripgrep/releases
# https://github.com/microsoft/ripgrep-prebuilt/releases
# ripgrep-v13.0.0-10-aarch64-apple-darwin.tar.gz
# ripgrep-v13.0.0-10-aarch64-pc-windows-msvc.zip
# ripgrep-v13.0.0-10-aarch64-unknown-linux-gnu.tar.gz
# ripgrep-v13.0.0-10-aarch64-unknown-linux-musl.tar.gz
# ripgrep-v13.0.0-10-arm-unknown-linux-gnueabihf.tar.gz
# ripgrep-v13.0.0-10-i686-pc-windows-msvc.zip
# ripgrep-v13.0.0-10-i686-unknown-linux-musl.tar.gz
# ripgrep-v13.0.0-10-powerpc64le-unknown-linux-gnu.tar.gz
# ripgrep-v13.0.0-10-s390x-unknown-linux-gnu.tar.gz
# ripgrep-v13.0.0-10-x86_64-apple-darwin.tar.gz
# ripgrep-v13.0.0-10-x86_64-pc-windows-msvc.zip
# ripgrep-v13.0.0-10-x86_64-unknown-linux-musl.tar.gz
# https://packages.debian.org/sid/amd64/ripgrep/filelist
# /usr/bin/rg
# https://repology.org/project/ripgrep/versions
function setup_util_ripgrep() (
source "$DOROTHY/sources/bash.bash"
# improve performance for detectable utilities with conditional assets
if setup-util "$@" --check --cli=rg; then
return 0
fi
# setup
local arch options=(
--name='ripgrep'
--cli='rg'
"$@"
APK='ripgrep' # ALPINE
APT='ripgrep' # UBUNTU
AUR='ripgrep' # ARCH
BREW='ripgrep'
BSD='ripgrep'
CARGO='ripgrep'
CHOCO='ripgrep'
EMERGE='sys-apps/ripgrep' # GENTOO
URPMI='ripgrep' # MAGEIA
NIX='ripgrep'
PORT='ripgrep'
RPM='ripgrep' # FEDORA
SCOOP='ripgrep'
TEA='+crates.io/ripgrep'
ZYPPER='ripgrep' # SUSE
)
function get_github_asset_url {
github-download \
--dry \
--slug='microsoft/ripgrep-prebuilt' \
--latest \
--asset-regexp="$(echo-escape-regexp -- "$1")$" | echo-first-line || :
}
function add_download_option {
options+=(
DOWNLOAD="$(get_github_asset_url "$1")"
DOWNLOAD_ARCHIVE_GLOB="$2"
)
}
arch="$(get-arch)"
if is-mac; then
if test "$arch" = 'a64'; then
add_download_option '-aarch64-apple-darwin.tar.gz' 'rg'
elif test "$arch" = 'x64'; then
add_download_option '-x86_64-apple-darwin.tar.gz' 'rg'
fi
elif is-linux; then
if test "$arch" = 'a64'; then
add_download_option '-aarch64-unknown-linux-musl.tar.gz' 'rg'
elif test "$arch" = 'a32'; then
add_download_option '-arm-unknown-linux-gnueabihf.tar.gz' 'rg'
elif test "$arch" = 'x64'; then
add_download_option '-x86_64-unknown-linux-musl.tar.gz' 'rg'
elif test "$arch" = 'x32'; then
add_download_option '-i686-unknown-linux-musl.tar.gz' 'rg'
fi
elif is-wsl; then
if test "$arch" = 'a64'; then
add_download_option '-aarch64-pc-windows-msvc.zip' 'rg.exe'
elif test "$arch" = 'x64'; then
add_download_option '-x86_64-pc-windows-msvc.zip' 'rg.exe'
elif test "$arch" = 'x32'; then
add_download_option '-i686-pc-windows-msvc.zip' 'rg.exe'
fi
fi
setup-util "${options[@]}"
)
# fire if invoked standalone
if test "$0" = "${BASH_SOURCE[0]}"; then
setup_util_ripgrep "$@"
fi