fpf-cli 1.6.38 → 1.6.39
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.
- package/fpf +52 -40
- package/package.json +1 -1
package/fpf
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
|
|
5
5
|
SCRIPT_NAME="fpf"
|
|
6
|
-
SCRIPT_VERSION="1.6.
|
|
6
|
+
SCRIPT_VERSION="1.6.39"
|
|
7
7
|
TMP_ROOT="${TMPDIR:-/tmp}/fpf"
|
|
8
8
|
SESSION_TMP_ROOT=""
|
|
9
9
|
HELP_FILE=""
|
|
@@ -98,17 +98,39 @@ loading_progress_mark_done() {
|
|
|
98
98
|
loading_progress_mark_state "${manager}" "done" "${detail}"
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
local
|
|
103
|
-
local char="$2"
|
|
104
|
-
local chunk=""
|
|
101
|
+
loading_indicator_terminal_cols() {
|
|
102
|
+
local cols="${COLUMNS:-}"
|
|
105
103
|
|
|
106
|
-
if ! [[ "${
|
|
107
|
-
|
|
104
|
+
if ! [[ "${cols}" =~ ^[0-9]+$ ]] || [[ "${cols}" -lt 40 ]]; then
|
|
105
|
+
if command_exists tput; then
|
|
106
|
+
cols="$(tput cols 2>/dev/null || true)"
|
|
107
|
+
fi
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
if ! [[ "${cols}" =~ ^[0-9]+$ ]] || [[ "${cols}" -lt 40 ]]; then
|
|
111
|
+
cols=120
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
printf "%s" "${cols}"
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
loading_indicator_fit_line() {
|
|
118
|
+
local line="$1"
|
|
119
|
+
local cols
|
|
120
|
+
local max_len
|
|
121
|
+
|
|
122
|
+
cols="$(loading_indicator_terminal_cols)"
|
|
123
|
+
max_len=$((cols - 1))
|
|
124
|
+
if [[ "${max_len}" -lt 20 ]]; then
|
|
125
|
+
max_len=20
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
if [[ "${#line}" -gt "${max_len}" ]]; then
|
|
129
|
+
printf "%s..." "${line:0:$((max_len - 3))}"
|
|
130
|
+
return
|
|
108
131
|
fi
|
|
109
132
|
|
|
110
|
-
printf
|
|
111
|
-
printf "%s" "${chunk// /${char}}"
|
|
133
|
+
printf "%s" "${line}"
|
|
112
134
|
}
|
|
113
135
|
|
|
114
136
|
loading_progress_snapshot() {
|
|
@@ -116,31 +138,22 @@ loading_progress_snapshot() {
|
|
|
116
138
|
local manager=""
|
|
117
139
|
local status=""
|
|
118
140
|
local detail=""
|
|
119
|
-
local bar_width="${FPF_LOADING_BAR_WIDTH:-26}"
|
|
120
141
|
local total=0
|
|
121
142
|
local done=0
|
|
122
143
|
local running=0
|
|
123
144
|
local queued=0
|
|
124
145
|
local progress_percent=0
|
|
125
|
-
local filled_width=0
|
|
126
|
-
local remaining_width=0
|
|
127
|
-
local bar=""
|
|
128
146
|
local -a active_details=()
|
|
129
147
|
local active_text=""
|
|
130
148
|
local phase_text=""
|
|
149
|
+
local active_total=0
|
|
150
|
+
local max_active_items=3
|
|
131
151
|
local idx
|
|
132
152
|
|
|
133
153
|
if [[ -z "${LOADING_PROGRESS_DIR}" || ! -d "${LOADING_PROGRESS_DIR}" ]]; then
|
|
134
154
|
return 0
|
|
135
155
|
fi
|
|
136
156
|
|
|
137
|
-
if ! [[ "${bar_width}" =~ ^[0-9]+$ ]] || [[ "${bar_width}" -lt 10 ]]; then
|
|
138
|
-
bar_width=26
|
|
139
|
-
fi
|
|
140
|
-
if [[ "${bar_width}" -gt 60 ]]; then
|
|
141
|
-
bar_width=60
|
|
142
|
-
fi
|
|
143
|
-
|
|
144
157
|
for status_file in "${LOADING_PROGRESS_DIR}"/*.status; do
|
|
145
158
|
[[ -f "${status_file}" ]] || continue
|
|
146
159
|
total=$((total + 1))
|
|
@@ -152,7 +165,10 @@ loading_progress_snapshot() {
|
|
|
152
165
|
;;
|
|
153
166
|
running)
|
|
154
167
|
running=$((running + 1))
|
|
155
|
-
|
|
168
|
+
active_total=$((active_total + 1))
|
|
169
|
+
if [[ "${#active_details[@]}" -lt "${max_active_items}" ]]; then
|
|
170
|
+
active_details+=("${manager}: ${detail:-work}")
|
|
171
|
+
fi
|
|
156
172
|
;;
|
|
157
173
|
*)
|
|
158
174
|
queued=$((queued + 1))
|
|
@@ -163,25 +179,18 @@ loading_progress_snapshot() {
|
|
|
163
179
|
[[ "${total}" -gt 0 ]] || return 0
|
|
164
180
|
|
|
165
181
|
progress_percent=$((done * 100 / total))
|
|
166
|
-
filled_width=$((done * bar_width / total))
|
|
167
|
-
if [[ "${done}" -ge "${total}" ]]; then
|
|
168
|
-
bar="$(loading_progress_repeat_char "${bar_width}" "=")"
|
|
169
|
-
else
|
|
170
|
-
remaining_width=$((bar_width - filled_width - 1))
|
|
171
|
-
bar="$(loading_progress_repeat_char "${filled_width}" "=")>"
|
|
172
|
-
if [[ "${remaining_width}" -gt 0 ]]; then
|
|
173
|
-
bar+=$(printf "%${remaining_width}s" "")
|
|
174
|
-
fi
|
|
175
|
-
fi
|
|
176
182
|
|
|
177
183
|
if [[ "${#active_details[@]}" -gt 0 ]]; then
|
|
178
184
|
active_text=""
|
|
179
185
|
for idx in "${!active_details[@]}"; do
|
|
180
186
|
if [[ -n "${active_text}" ]]; then
|
|
181
|
-
active_text+="
|
|
187
|
+
active_text+=", "
|
|
182
188
|
fi
|
|
183
189
|
active_text+="${active_details[$idx]}"
|
|
184
190
|
done
|
|
191
|
+
if [[ "${active_total}" -gt "${#active_details[@]}" ]]; then
|
|
192
|
+
active_text+=", +$((active_total - ${#active_details[@]}))"
|
|
193
|
+
fi
|
|
185
194
|
phase_text="active: ${active_text}"
|
|
186
195
|
elif [[ "${queued}" -gt 0 ]]; then
|
|
187
196
|
phase_text="starting queued managers (${queued} remaining)"
|
|
@@ -189,7 +198,7 @@ loading_progress_snapshot() {
|
|
|
189
198
|
phase_text="finalizing combined results"
|
|
190
199
|
fi
|
|
191
200
|
|
|
192
|
-
printf "
|
|
201
|
+
printf "%3s%% (%s/%s) | %s" "${progress_percent}" "${done}" "${total}" "${phase_text}"
|
|
193
202
|
}
|
|
194
203
|
|
|
195
204
|
start_loading_indicator() {
|
|
@@ -206,6 +215,7 @@ start_loading_indicator() {
|
|
|
206
215
|
local started_epoch
|
|
207
216
|
local elapsed_seconds=0
|
|
208
217
|
local snapshot=""
|
|
218
|
+
local line_output=""
|
|
209
219
|
|
|
210
220
|
started_epoch="$(date +%s)"
|
|
211
221
|
if ! [[ "${started_epoch}" =~ ^[0-9]+$ ]]; then
|
|
@@ -220,11 +230,13 @@ start_loading_indicator() {
|
|
|
220
230
|
|
|
221
231
|
snapshot="$(loading_progress_snapshot)"
|
|
222
232
|
if [[ -n "${snapshot}" ]]; then
|
|
223
|
-
|
|
233
|
+
line_output="${message} ${snapshot} | ${elapsed_seconds}s"
|
|
224
234
|
else
|
|
225
|
-
|
|
235
|
+
line_output="${message} working | ${elapsed_seconds}s"
|
|
226
236
|
fi
|
|
227
|
-
|
|
237
|
+
line_output="$(loading_indicator_fit_line "${line_output}")"
|
|
238
|
+
printf "\r\033[2K%s" "${line_output}" >&2
|
|
239
|
+
sleep 0.15
|
|
228
240
|
done
|
|
229
241
|
) &
|
|
230
242
|
LOADING_INDICATOR_PID="$!"
|
|
@@ -2901,7 +2913,7 @@ mark_installed_packages() {
|
|
|
2901
2913
|
manager_match_count=0
|
|
2902
2914
|
fi
|
|
2903
2915
|
|
|
2904
|
-
loading_progress_mark_running "${manager}" "
|
|
2916
|
+
loading_progress_mark_running "${manager}" "mark installed (${manager_match_count})"
|
|
2905
2917
|
installed_file="$(mktemp "${SESSION_TMP_ROOT}/installed.${manager}.XXXXXX")"
|
|
2906
2918
|
manager_installed_names_cached "${manager}" "${installed_file}" || true
|
|
2907
2919
|
installed_match_count=0
|
|
@@ -2995,7 +3007,7 @@ collect_search_display_rows() {
|
|
|
2995
3007
|
local local_source_file
|
|
2996
3008
|
local result_count=0
|
|
2997
3009
|
|
|
2998
|
-
loading_progress_mark_running "${manager}" "
|
|
3010
|
+
loading_progress_mark_running "${manager}" "query index"
|
|
2999
3011
|
local_source_file="$(mktemp "${SESSION_TMP_ROOT}/source.XXXXXX")"
|
|
3000
3012
|
manager_search_entries "${manager}" "${query}" >"${local_source_file}" || true
|
|
3001
3013
|
if [[ -s "${local_source_file}" ]]; then
|
|
@@ -3012,7 +3024,7 @@ collect_search_display_rows() {
|
|
|
3012
3024
|
if [[ -s "${part_file}" ]]; then
|
|
3013
3025
|
result_count="$(awk 'END { print NR + 0 }' "${part_file}")"
|
|
3014
3026
|
fi
|
|
3015
|
-
loading_progress_mark_running "${manager}" "${result_count}
|
|
3027
|
+
loading_progress_mark_running "${manager}" "${result_count} indexed; mark installed"
|
|
3016
3028
|
) &
|
|
3017
3029
|
gather_pids+=("$!")
|
|
3018
3030
|
done
|
|
@@ -3069,7 +3081,7 @@ collect_installed_display_rows() {
|
|
|
3069
3081
|
local local_source_file
|
|
3070
3082
|
local result_count=0
|
|
3071
3083
|
|
|
3072
|
-
loading_progress_mark_running "${manager}" "
|
|
3084
|
+
loading_progress_mark_running "${manager}" "read installed"
|
|
3073
3085
|
local_source_file="$(mktemp "${SESSION_TMP_ROOT}/source.XXXXXX")"
|
|
3074
3086
|
manager_installed_entries "${manager}" >"${local_source_file}" || true
|
|
3075
3087
|
if [[ -s "${local_source_file}" ]]; then
|