just-bashit 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- just_bashit/__init__.py +3 -0
- just_bashit/_launcher.py +23 -0
- just_bashit/datetime.sh +115 -0
- just_bashit/environment.sh +204 -0
- just_bashit/file.sh +257 -0
- just_bashit/format.sh +223 -0
- just_bashit/function-template.sh +139 -0
- just_bashit/get-jb.sh +177 -0
- just_bashit/inspect.sh +220 -0
- just_bashit/install-deps.sh +300 -0
- just_bashit/just-runit +682 -0
- just_bashit/logging.sh +174 -0
- just_bashit/match.sh +64 -0
- just_bashit/network.sh +172 -0
- just_bashit/path.sh +79 -0
- just_bashit/pkg.sh +155 -0
- just_bashit/script-template +113 -0
- just_bashit/template.toml +80 -0
- just_bashit/toml.sh +331 -0
- just_bashit-0.2.0.dist-info/METADATA +64 -0
- just_bashit-0.2.0.dist-info/RECORD +23 -0
- just_bashit-0.2.0.dist-info/WHEEL +4 -0
- just_bashit-0.2.0.dist-info/entry_points.txt +4 -0
just_bashit/format.sh
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ############################################################################
|
|
3
|
+
# LIBRARY: format.sh #
|
|
4
|
+
# PACKAGE: just-bashit version 0.2.0 #
|
|
5
|
+
# ############################################################################
|
|
6
|
+
|
|
7
|
+
# Enforce sourcing of the script by taking advantage of the fact that return
|
|
8
|
+
# only works if sourced and errors otherwise.
|
|
9
|
+
(return 0 2>/dev/null) || (echo "This file must be sourced." && exit)
|
|
10
|
+
|
|
11
|
+
trim-from() {
|
|
12
|
+
|
|
13
|
+
read -r -d '' HELP <<-'EOF' || true
|
|
14
|
+
Usage: trim-from [-hrfe] [m MARKER] STRING
|
|
15
|
+
|
|
16
|
+
Trim STRING from MARKER (first occurence, inclusive) to end.
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
-h Show this message and exit.
|
|
20
|
+
-m MARKER Character(s) to trim from. Default is '.'.
|
|
21
|
+
-r Reverse trim. Trim from MARKER to beginning.
|
|
22
|
+
-g Greedy. Trim from last occurence of marker.
|
|
23
|
+
-k Keep MARKER instead of including in trim.
|
|
24
|
+
|
|
25
|
+
Arguments:
|
|
26
|
+
STRING The text to trim.
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
trim-from 12.45 # gives 12
|
|
30
|
+
trim-from -r 12.45 # gives 45
|
|
31
|
+
trim-from 12.4.45 # gives 12.4
|
|
32
|
+
trim-from -g 12.4.45 # gives 12
|
|
33
|
+
trim-from -kg 12.4.45 # gives 12.
|
|
34
|
+
trim-from -m MA "HEYMA!" # gives HEY
|
|
35
|
+
trim-from -rm MA "HEYMA!" # gives !
|
|
36
|
+
EOF
|
|
37
|
+
|
|
38
|
+
# Initialize all referenced variables
|
|
39
|
+
local OPTARG=""
|
|
40
|
+
local OPTIND=0
|
|
41
|
+
local -i GREEDY=0
|
|
42
|
+
local -i REVERSE=0
|
|
43
|
+
local -i KEEP=0
|
|
44
|
+
local MARKER='.'
|
|
45
|
+
local RESULT=""
|
|
46
|
+
|
|
47
|
+
# Specify options. Add ':' to start and after options that take arguments.
|
|
48
|
+
while getopts ":hrgkm:" option; do
|
|
49
|
+
|
|
50
|
+
# Parse options.
|
|
51
|
+
case $option in
|
|
52
|
+
|
|
53
|
+
# h for help.
|
|
54
|
+
h)
|
|
55
|
+
echo "${HELP}"
|
|
56
|
+
return 0
|
|
57
|
+
;;
|
|
58
|
+
|
|
59
|
+
# Unrecognized options sets $option to '?'.
|
|
60
|
+
\?)
|
|
61
|
+
echo "Invalid option: -${OPTARG}"
|
|
62
|
+
echo "${HELP}"
|
|
63
|
+
return 0
|
|
64
|
+
;;
|
|
65
|
+
|
|
66
|
+
r)
|
|
67
|
+
REVERSE=1
|
|
68
|
+
;;
|
|
69
|
+
|
|
70
|
+
g)
|
|
71
|
+
GREEDY=1
|
|
72
|
+
;;
|
|
73
|
+
|
|
74
|
+
k)
|
|
75
|
+
KEEP=1
|
|
76
|
+
;;
|
|
77
|
+
|
|
78
|
+
m)
|
|
79
|
+
MARKER="${OPTARG}"
|
|
80
|
+
;;
|
|
81
|
+
|
|
82
|
+
esac
|
|
83
|
+
|
|
84
|
+
done
|
|
85
|
+
|
|
86
|
+
# Remove options from the input list $@ so the first remaining argument is $1.
|
|
87
|
+
shift "$((OPTIND - 1))"
|
|
88
|
+
|
|
89
|
+
# Build the string operator
|
|
90
|
+
local STRING=${1:-}
|
|
91
|
+
if ((REVERSE)); then
|
|
92
|
+
|
|
93
|
+
if ((GREEDY)); then
|
|
94
|
+
RESULT="${STRING##*"${MARKER}"}"
|
|
95
|
+
else
|
|
96
|
+
RESULT="${STRING#*"${MARKER}"}"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
((KEEP)) && RESULT="${MARKER}${RESULT}"
|
|
100
|
+
|
|
101
|
+
else
|
|
102
|
+
|
|
103
|
+
if ((GREEDY)); then
|
|
104
|
+
RESULT="${STRING%%"${MARKER}"*}"
|
|
105
|
+
else
|
|
106
|
+
RESULT="${STRING%"${MARKER}"*}"
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
((KEEP)) && RESULT+="${MARKER}"
|
|
110
|
+
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
printf %s "${RESULT}"
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
color-echo() {
|
|
118
|
+
|
|
119
|
+
read -r -d '' HELP <<-'EOF' || true
|
|
120
|
+
Usage: color-echo [OPTIONS] STRING
|
|
121
|
+
|
|
122
|
+
Colorize text (default white) and "echo" (printf + trailing newline).
|
|
123
|
+
|
|
124
|
+
Options:
|
|
125
|
+
-h Show this message and exit.
|
|
126
|
+
-c COLOR One of [black|red|green|yellow|blue|magenta|cyan|white].
|
|
127
|
+
-b Bright or bold version of the requested color.
|
|
128
|
+
|
|
129
|
+
Arguments:
|
|
130
|
+
STRING The text to colorize and print.
|
|
131
|
+
EOF
|
|
132
|
+
|
|
133
|
+
# Initialize all referenced variables
|
|
134
|
+
local BOLD=1
|
|
135
|
+
local OPTARG=""
|
|
136
|
+
local OPTIND=0
|
|
137
|
+
local BEGIN="\033["
|
|
138
|
+
local RESET="\033[0m"
|
|
139
|
+
local DEBUG=0
|
|
140
|
+
local ATTRIBUTE=0
|
|
141
|
+
local FOREGROUND=37
|
|
142
|
+
|
|
143
|
+
# Specify options. Add ':' to start and after options that take arguments.
|
|
144
|
+
while getopts ":hbdc:" option; do
|
|
145
|
+
|
|
146
|
+
# Parse options.
|
|
147
|
+
case $option in
|
|
148
|
+
|
|
149
|
+
# h for help.
|
|
150
|
+
h)
|
|
151
|
+
echo "${HELP}"
|
|
152
|
+
return 0
|
|
153
|
+
;;
|
|
154
|
+
|
|
155
|
+
# Unrecognized options set $option to '?'.
|
|
156
|
+
\?)
|
|
157
|
+
echo "Invalid option: -${OPTARG}"
|
|
158
|
+
echo "${HELP}"
|
|
159
|
+
return 0
|
|
160
|
+
;;
|
|
161
|
+
|
|
162
|
+
b)
|
|
163
|
+
ATTRIBUTE="${BOLD}"
|
|
164
|
+
;;
|
|
165
|
+
|
|
166
|
+
d)
|
|
167
|
+
DEBUG=1
|
|
168
|
+
;;
|
|
169
|
+
|
|
170
|
+
c)
|
|
171
|
+
# ${var,,} requires bash 4+; tr works on bash 3.2 (macOS default).
|
|
172
|
+
local _color_lc
|
|
173
|
+
_color_lc="$(printf '%s' "${OPTARG}" | tr '[:upper:]' '[:lower:]')"
|
|
174
|
+
case "${_color_lc}" in
|
|
175
|
+
|
|
176
|
+
black)
|
|
177
|
+
FOREGROUND=30
|
|
178
|
+
;;
|
|
179
|
+
red)
|
|
180
|
+
FOREGROUND=31
|
|
181
|
+
;;
|
|
182
|
+
green)
|
|
183
|
+
FOREGROUND=32
|
|
184
|
+
;;
|
|
185
|
+
yellow)
|
|
186
|
+
FOREGROUND=33
|
|
187
|
+
;;
|
|
188
|
+
blue)
|
|
189
|
+
FOREGROUND=34
|
|
190
|
+
;;
|
|
191
|
+
magenta)
|
|
192
|
+
FOREGROUND=35
|
|
193
|
+
;;
|
|
194
|
+
cyan)
|
|
195
|
+
FOREGROUND=36
|
|
196
|
+
;;
|
|
197
|
+
white)
|
|
198
|
+
FOREGROUND=37
|
|
199
|
+
;;
|
|
200
|
+
*)
|
|
201
|
+
echo "Error: invalid color ${OPTARG}" 1>&2
|
|
202
|
+
return 1
|
|
203
|
+
;;
|
|
204
|
+
|
|
205
|
+
esac
|
|
206
|
+
;;
|
|
207
|
+
|
|
208
|
+
esac
|
|
209
|
+
|
|
210
|
+
done
|
|
211
|
+
|
|
212
|
+
# Remove options from the input list $@ so the first remaining argument is $1.
|
|
213
|
+
shift "$((OPTIND - 1))"
|
|
214
|
+
|
|
215
|
+
# Print the formatted result
|
|
216
|
+
local TEXTFIELD=${*:-""}
|
|
217
|
+
local FORMATTED_TEXT="${BEGIN}${ATTRIBUTE};${FOREGROUND}m${TEXTFIELD}${RESET}"
|
|
218
|
+
if ((DEBUG)); then
|
|
219
|
+
printf %q "${FORMATTED_TEXT}\\n"
|
|
220
|
+
else
|
|
221
|
+
printf %b "${FORMATTED_TEXT}\\n"
|
|
222
|
+
fi
|
|
223
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ############################################################################
|
|
3
|
+
# LIBRARY: function-template.sh #
|
|
4
|
+
# PACKAGE: just-bashit version 0.2.0 #
|
|
5
|
+
# ############################################################################
|
|
6
|
+
|
|
7
|
+
# Enforce sourcing of the script by taking advantage of the fact that return
|
|
8
|
+
# only works if sourced and errors otherwise.
|
|
9
|
+
(return 0 2>/dev/null) || (echo "This file must be sourced." && exit)
|
|
10
|
+
|
|
11
|
+
full-on-template() {
|
|
12
|
+
|
|
13
|
+
##########################################################################
|
|
14
|
+
# This is a 'full-on' template. Take only what you need. A lot of useful #
|
|
15
|
+
# functions don't need this complexity. Take a look at the minimalist #
|
|
16
|
+
# template that immediately follows this one. #
|
|
17
|
+
##########################################################################
|
|
18
|
+
|
|
19
|
+
# Use 'heredoc' for help to make formatting easier: WYSIWYG
|
|
20
|
+
# Use two spaces for indent of section content as well as minimum space
|
|
21
|
+
# between option/argument names and descriptions, lining them all up.
|
|
22
|
+
local HELP
|
|
23
|
+
IFS= read -r -d '' HELP <<-'EOF'
|
|
24
|
+
Usage: full-on-template [OPTIONS] [-p PARAM] [ARGS] ...
|
|
25
|
+
|
|
26
|
+
Function Title and Short Summary.
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
-h Show this message and exit.
|
|
30
|
+
-p PARAM Option that accepts an argument stored in $OPTARG.
|
|
31
|
+
-v Show the version and exit.
|
|
32
|
+
|
|
33
|
+
Arguments:
|
|
34
|
+
MYCMD Some command or other stored in $1
|
|
35
|
+
MYVAR Some variable or other stored in $2
|
|
36
|
+
EOF
|
|
37
|
+
|
|
38
|
+
# Initialize all referenced variables
|
|
39
|
+
local PARAM=""
|
|
40
|
+
local OPTARG=""
|
|
41
|
+
local OPTIND=0 # Particularly important when sourcing
|
|
42
|
+
|
|
43
|
+
# Specify options. Add ':' to start and after options that take arguments.
|
|
44
|
+
while getopts ":hp:v" option; do
|
|
45
|
+
|
|
46
|
+
# Parse options.
|
|
47
|
+
case $option in
|
|
48
|
+
|
|
49
|
+
# h for help.
|
|
50
|
+
h)
|
|
51
|
+
echo "${HELP}"
|
|
52
|
+
return 0
|
|
53
|
+
;;
|
|
54
|
+
|
|
55
|
+
# Unrecognized options set $option to '?'.
|
|
56
|
+
\?)
|
|
57
|
+
echo "Invalid option: -${OPTARG}"
|
|
58
|
+
echo "${HELP}"
|
|
59
|
+
return 0
|
|
60
|
+
;;
|
|
61
|
+
|
|
62
|
+
# Option taking a parameter stored for later processing.
|
|
63
|
+
p)
|
|
64
|
+
PARAM="${OPTARG}"
|
|
65
|
+
;;
|
|
66
|
+
|
|
67
|
+
# Option processed immediately
|
|
68
|
+
v)
|
|
69
|
+
echo "X.Y.Z"
|
|
70
|
+
return 0
|
|
71
|
+
;;
|
|
72
|
+
|
|
73
|
+
esac
|
|
74
|
+
|
|
75
|
+
done
|
|
76
|
+
|
|
77
|
+
# Remove options from the input list $@ so the first remaining argument is $1.
|
|
78
|
+
shift "$((OPTIND - 1))"
|
|
79
|
+
|
|
80
|
+
# Make sure all referenced arguments are initialized AFTER getopts processing
|
|
81
|
+
local MYCMD=${1:-} # Conditional assignment to $1 if exists or empty string
|
|
82
|
+
|
|
83
|
+
# Process option -p where PARAM could be a command, filename, etc...
|
|
84
|
+
if [ -n "${PARAM}" ]; then
|
|
85
|
+
echo "Option -p specified with argument: ${PARAM}"
|
|
86
|
+
# Do something with PARAM ...
|
|
87
|
+
return 0
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# Process arguments individually
|
|
91
|
+
# Some command
|
|
92
|
+
somecmd() { echo "Executing cmd()"; }
|
|
93
|
+
if [ "${MYCMD}" == 'SOMECMD' ]; then
|
|
94
|
+
somecmd
|
|
95
|
+
return 0
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# Process all arguments in a loop
|
|
99
|
+
for arg in "${@}"; do
|
|
100
|
+
echo "Processing argument: ${arg} from \$@ in a loop"
|
|
101
|
+
# Do something with the argument
|
|
102
|
+
done
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
minimalist-template() {
|
|
107
|
+
|
|
108
|
+
# Assume we are running under -u so initialize any referenced variables
|
|
109
|
+
ARG1=${1:-}
|
|
110
|
+
|
|
111
|
+
# Define a sub-command or action to use
|
|
112
|
+
something-cool() { echo "Doing something cool with ${ARG1}"; }
|
|
113
|
+
|
|
114
|
+
# Forget getopts, manually parse for handful of inputs
|
|
115
|
+
case "${ARG1}" in
|
|
116
|
+
-h | "")
|
|
117
|
+
|
|
118
|
+
# Prefer help to commenst since it's user-oriented and runtime-available.
|
|
119
|
+
echo 'Usage: minimalist-template [OPTIONS] [-p PARAM] [ARGS] ...'
|
|
120
|
+
echo
|
|
121
|
+
echo ' Summarize what cool thing this function does.'
|
|
122
|
+
echo
|
|
123
|
+
echo 'Options:'
|
|
124
|
+
echo ' -h Show this message and exit.'
|
|
125
|
+
echo
|
|
126
|
+
echo 'Arguments:'
|
|
127
|
+
# shellcheck disable=SC2016
|
|
128
|
+
echo ' MYVAR Some variable or other stored in $1'
|
|
129
|
+
return 0
|
|
130
|
+
;;
|
|
131
|
+
|
|
132
|
+
*)
|
|
133
|
+
|
|
134
|
+
something-cool "${ARG1}"
|
|
135
|
+
;;
|
|
136
|
+
|
|
137
|
+
esac
|
|
138
|
+
|
|
139
|
+
}
|
just_bashit/get-jb.sh
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ############################################################################
|
|
3
|
+
# SCRIPT: get-jb.sh #
|
|
4
|
+
# PACKAGE: just-bashit version 0.2.0 #
|
|
5
|
+
# ############################################################################
|
|
6
|
+
# Installs just-runit (just-buildit / jb / jbx) to ~/.local/bin. #
|
|
7
|
+
# #
|
|
8
|
+
# Must be sourced so PATH exports reach the calling shell: #
|
|
9
|
+
# . <(curl -sSL https://just-buildit.github.io/get-jb.sh) #
|
|
10
|
+
# #
|
|
11
|
+
# To force reinstall even when already current: #
|
|
12
|
+
# JB_REINSTALL=1 . <(curl -sSL https://just-buildit.github.io/get-jb.sh)
|
|
13
|
+
# ############################################################################
|
|
14
|
+
|
|
15
|
+
# Wrapped in a function so locals don't leak and we can clean up afterward.
|
|
16
|
+
_jb_install() {
|
|
17
|
+
|
|
18
|
+
local INSTALL_DIR="${HOME}/.local/bin"
|
|
19
|
+
local RAW_BASE
|
|
20
|
+
RAW_BASE="https://raw.githubusercontent.com/just-buildit/just-bashit/main/src"
|
|
21
|
+
local RUNIT_URL="${RAW_BASE}/just-runit"
|
|
22
|
+
local BASHRC="${HOME}/.bashrc"
|
|
23
|
+
|
|
24
|
+
local BOLD="\033[1m"
|
|
25
|
+
local GREEN="\033[1;32m"
|
|
26
|
+
local CYAN="\033[1;36m"
|
|
27
|
+
local YELLOW="\033[1;33m"
|
|
28
|
+
local RESET="\033[0m"
|
|
29
|
+
|
|
30
|
+
_jb_say() { printf "${CYAN} -> ${RESET}${BOLD}%s${RESET}\n" "$*"; }
|
|
31
|
+
_jb_ok() { printf "${GREEN} ok ${RESET}%s\n" "$*"; }
|
|
32
|
+
_jb_warn() { printf "${YELLOW} !! ${RESET}%s\n" "$*"; }
|
|
33
|
+
|
|
34
|
+
# -- disclaimer ------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
printf '%b' "${YELLOW}${BOLD}"
|
|
37
|
+
printf ' +----------------------------------------------------------+\n'
|
|
38
|
+
printf ' | This script is provided AS IS, without warranty of any |\n'
|
|
39
|
+
printf ' | kind. Review the source before running: |\n'
|
|
40
|
+
printf ' | https://just-buildit.github.io/get-jb.sh |\n'
|
|
41
|
+
printf ' | |\n'
|
|
42
|
+
printf ' | The tool it installs fetches and executes arbitrary |\n'
|
|
43
|
+
printf ' | code from URLs you provide. It performs no review, |\n'
|
|
44
|
+
printf ' | scanning, or sandboxing. You are solely responsible |\n'
|
|
45
|
+
printf ' | for what you choose to run. |\n'
|
|
46
|
+
printf ' | |\n'
|
|
47
|
+
printf ' | Use at your own risk. |\n'
|
|
48
|
+
printf ' +----------------------------------------------------------+\n'
|
|
49
|
+
printf '%b\n' "${RESET}"
|
|
50
|
+
|
|
51
|
+
# -- install dir -----------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
_jb_say "install dir: ${INSTALL_DIR}"
|
|
54
|
+
mkdir -p "${INSTALL_DIR}"
|
|
55
|
+
|
|
56
|
+
# -- version-aware download -----------------------------------------------
|
|
57
|
+
|
|
58
|
+
local tmp_runit
|
|
59
|
+
tmp_runit=$(mktemp /tmp/just-runit.XXXXXX)
|
|
60
|
+
# shellcheck disable=SC2064
|
|
61
|
+
trap "rm -f '${tmp_runit}'" RETURN
|
|
62
|
+
|
|
63
|
+
_jb_say "fetching jb from ${RUNIT_URL}"
|
|
64
|
+
if ! curl -sSL --proto '=https' --tlsv1.2 -o "${tmp_runit}" "${RUNIT_URL}"; then
|
|
65
|
+
printf "\033[1;31m !! \033[0mfailed to download jb\n" >&2
|
|
66
|
+
return 1
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
local new_ver
|
|
70
|
+
new_ver=$(grep '^_VERSION=' "${tmp_runit}" | cut -d'"' -f2)
|
|
71
|
+
new_ver="${new_ver:-unknown}"
|
|
72
|
+
|
|
73
|
+
local installed="${INSTALL_DIR}/just-runit"
|
|
74
|
+
if [[ -x ${installed} ]]; then
|
|
75
|
+
local cur_ver
|
|
76
|
+
cur_ver=$(grep '^_VERSION=' "${installed}" | cut -d'"' -f2)
|
|
77
|
+
cur_ver="${cur_ver:-unknown}"
|
|
78
|
+
|
|
79
|
+
if [[ ${cur_ver} == "${new_ver}" && ${JB_REINSTALL:-0} != "1" ]]; then
|
|
80
|
+
_jb_ok "already at v${cur_ver} — set JB_REINSTALL=1 to force reinstall"
|
|
81
|
+
else
|
|
82
|
+
if [[ ${cur_ver} != "${new_ver}" ]]; then
|
|
83
|
+
_jb_say "upgrading v${cur_ver} -> v${new_ver}"
|
|
84
|
+
else
|
|
85
|
+
_jb_say "reinstalling v${new_ver}"
|
|
86
|
+
fi
|
|
87
|
+
cp "${tmp_runit}" "${installed}"
|
|
88
|
+
chmod +x "${installed}"
|
|
89
|
+
_jb_ok "jb v${new_ver} installed"
|
|
90
|
+
fi
|
|
91
|
+
else
|
|
92
|
+
_jb_say "installing v${new_ver}"
|
|
93
|
+
cp "${tmp_runit}" "${installed}"
|
|
94
|
+
chmod +x "${installed}"
|
|
95
|
+
_jb_ok "jb v${new_ver} installed"
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# -- remove stale aliases from prior naming schemes -----------------------
|
|
99
|
+
|
|
100
|
+
local stale
|
|
101
|
+
for stale in jr jx; do
|
|
102
|
+
local stale_path="${INSTALL_DIR}/${stale}"
|
|
103
|
+
if [[ -L ${stale_path} && "$(readlink -f "${stale_path}")" == "$(readlink -f "${INSTALL_DIR}/just-runit")" ]]; then
|
|
104
|
+
rm -f "${stale_path}"
|
|
105
|
+
_jb_warn "removed stale alias: ${stale}"
|
|
106
|
+
fi
|
|
107
|
+
done
|
|
108
|
+
|
|
109
|
+
# -- just-buildit symlink (always created — canonical long name) -----------
|
|
110
|
+
|
|
111
|
+
ln -sf just-runit "${INSTALL_DIR}/just-buildit"
|
|
112
|
+
_jb_ok "just-buildit -> just-runit"
|
|
113
|
+
|
|
114
|
+
# -- jb symlink (short alias — skipped if jb is already someone else's) ---
|
|
115
|
+
|
|
116
|
+
local _jb_cmd
|
|
117
|
+
_jb_cmd="$(command -v jb 2>/dev/null || true)"
|
|
118
|
+
local _JB_NAME="jb"
|
|
119
|
+
if [[ -n ${_jb_cmd} && "$(readlink -f "${_jb_cmd}")" != "$(readlink -f "${INSTALL_DIR}/just-runit")" ]]; then
|
|
120
|
+
_jb_warn "'jb' is already in use (${_jb_cmd}) — skipping short alias"
|
|
121
|
+
_jb_warn "use 'just-buildit' instead (always available)"
|
|
122
|
+
_JB_NAME="just-buildit"
|
|
123
|
+
else
|
|
124
|
+
ln -sf just-runit "${INSTALL_DIR}/jb"
|
|
125
|
+
_jb_ok "jb -> just-runit"
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
# -- jbx symlink (runner shorthand, always created) -----------------------
|
|
129
|
+
|
|
130
|
+
ln -sf just-runit "${INSTALL_DIR}/jbx"
|
|
131
|
+
_jb_ok "jbx -> just-runit"
|
|
132
|
+
|
|
133
|
+
# -- PATH ------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
if [[ ":${PATH}:" != *":${INSTALL_DIR}:"* ]]; then
|
|
136
|
+
_jb_say "adding ${INSTALL_DIR} to PATH (current shell)"
|
|
137
|
+
export PATH="${INSTALL_DIR}:${PATH}"
|
|
138
|
+
|
|
139
|
+
# shellcheck disable=SC2016
|
|
140
|
+
local entry='export PATH="${HOME}/.local/bin:${PATH}"'
|
|
141
|
+
if ! grep -qF '.local/bin' "${BASHRC}" 2>/dev/null; then
|
|
142
|
+
_jb_say "persisting PATH to ${BASHRC}"
|
|
143
|
+
printf '\n%s\n' "${entry}" >>"${BASHRC}"
|
|
144
|
+
_jb_ok "added to ${BASHRC}"
|
|
145
|
+
else
|
|
146
|
+
_jb_warn "${BASHRC} already references .local/bin — skipped"
|
|
147
|
+
fi
|
|
148
|
+
else
|
|
149
|
+
_jb_ok "${INSTALL_DIR} already in PATH"
|
|
150
|
+
fi
|
|
151
|
+
|
|
152
|
+
# -- uv (enables Python PEP 723 dep resolution) ---------------------------
|
|
153
|
+
|
|
154
|
+
if command -v uv >/dev/null 2>&1; then
|
|
155
|
+
_jb_ok "uv found — Python PEP 723 support ready"
|
|
156
|
+
else
|
|
157
|
+
_jb_say "installing uv (Python PEP 723 support)"
|
|
158
|
+
"${INSTALL_DIR}/just-runit" https://astral.sh/uv/install.sh
|
|
159
|
+
if command -v uv >/dev/null 2>&1; then
|
|
160
|
+
_jb_ok "uv installed"
|
|
161
|
+
else
|
|
162
|
+
_jb_warn "uv installed — open a new shell if 'uv' isn't found"
|
|
163
|
+
fi
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
# -- confirm ---------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
printf '\n%b\n\n' "${GREEN}${BOLD} just-buildit is ready.${RESET}"
|
|
169
|
+
printf ' %b%s -h%b show help\n' \
|
|
170
|
+
"${BOLD}" "${_JB_NAME}" "${RESET}"
|
|
171
|
+
printf ' %b%s run just-bashit:datetime iso-8601-basic%b quick test\n\n' \
|
|
172
|
+
"${BOLD}" "${_JB_NAME}" "${RESET}"
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
_jb_install "$@"
|
|
177
|
+
unset -f _jb_install _jb_say _jb_ok _jb_warn
|