fpf-cli 1.6.46 → 1.6.48
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 +94 -10
- 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.48"
|
|
7
7
|
TMP_ROOT="${TMPDIR:-/tmp}/fpf"
|
|
8
8
|
SESSION_TMP_ROOT=""
|
|
9
9
|
HELP_FILE=""
|
|
@@ -659,7 +659,24 @@ brew_catalog_state_token() {
|
|
|
659
659
|
printf "state=unknown"
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
|
|
662
|
+
brew_catalog_state_cache_ttl_seconds() {
|
|
663
|
+
local ttl="${FPF_BREW_CATALOG_STATE_TTL:-300}"
|
|
664
|
+
|
|
665
|
+
if ! [[ "${ttl}" =~ ^[0-9]+$ ]]; then
|
|
666
|
+
ttl=300
|
|
667
|
+
fi
|
|
668
|
+
|
|
669
|
+
printf "%s" "${ttl}"
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
brew_catalog_state_cache_scope_hash() {
|
|
673
|
+
local scope_token
|
|
674
|
+
|
|
675
|
+
scope_token="fixtures=${FPF_TEST_FIXTURES:-0};fixture_dir=${FPF_TEST_FIXTURE_DIR:-}"
|
|
676
|
+
cache_cksum "${scope_token}"
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
cache_search_catalog_fingerprint_uncached() {
|
|
663
680
|
local manager="$1"
|
|
664
681
|
local command_path=""
|
|
665
682
|
local state_token="state=unknown"
|
|
@@ -681,6 +698,42 @@ cache_search_catalog_fingerprint() {
|
|
|
681
698
|
printf "%s|cmd=%s|%s" "$(cache_fingerprint "${manager}" "" "search-catalog")" "${command_path}" "${state_token}"
|
|
682
699
|
}
|
|
683
700
|
|
|
701
|
+
cache_search_catalog_fingerprint() {
|
|
702
|
+
local manager="$1"
|
|
703
|
+
local state_cache_key=""
|
|
704
|
+
local state_cache_file=""
|
|
705
|
+
local state_cache_ttl=0
|
|
706
|
+
local state_cache_tmp=""
|
|
707
|
+
local state_cache_scope_hash=""
|
|
708
|
+
|
|
709
|
+
if [[ "${manager}" != "brew" ]]; then
|
|
710
|
+
cache_search_catalog_fingerprint_uncached "${manager}"
|
|
711
|
+
return
|
|
712
|
+
fi
|
|
713
|
+
|
|
714
|
+
initialize_cache_root
|
|
715
|
+
|
|
716
|
+
state_cache_scope_hash="$(brew_catalog_state_cache_scope_hash)"
|
|
717
|
+
state_cache_key="state/search-catalog-fingerprint/${manager}.${state_cache_scope_hash}.txt"
|
|
718
|
+
state_cache_file="$(cache_path_for_key "${state_cache_key}")"
|
|
719
|
+
state_cache_ttl="$(brew_catalog_state_cache_ttl_seconds)"
|
|
720
|
+
|
|
721
|
+
if [[ "${state_cache_ttl}" -gt 0 && -s "${state_cache_file}" ]] && cache_is_fresh_with_ttl "${state_cache_key}" "${state_cache_ttl}"; then
|
|
722
|
+
cat "${state_cache_file}"
|
|
723
|
+
return
|
|
724
|
+
fi
|
|
725
|
+
|
|
726
|
+
state_cache_tmp="$(mktemp "${SESSION_TMP_ROOT}/search-catalog-fingerprint.XXXXXX")"
|
|
727
|
+
cache_search_catalog_fingerprint_uncached "${manager}" >"${state_cache_tmp}" || true
|
|
728
|
+
|
|
729
|
+
if [[ -s "${state_cache_tmp}" ]]; then
|
|
730
|
+
cache_store_key_from_file "${state_cache_key}" "${manager}" "${state_cache_tmp}"
|
|
731
|
+
cat "${state_cache_tmp}"
|
|
732
|
+
fi
|
|
733
|
+
|
|
734
|
+
rm -f "${state_cache_tmp}"
|
|
735
|
+
}
|
|
736
|
+
|
|
684
737
|
cache_search_catalog_key() {
|
|
685
738
|
local manager="$1"
|
|
686
739
|
local fingerprint="$2"
|
|
@@ -3290,6 +3343,7 @@ collect_installed_display_rows() {
|
|
|
3290
3343
|
build_dynamic_reload_command() {
|
|
3291
3344
|
local manager_override="$1"
|
|
3292
3345
|
local fallback_file="$2"
|
|
3346
|
+
local manager_list_csv="${3:-}"
|
|
3293
3347
|
local script_path="${BASH_SOURCE[0]}"
|
|
3294
3348
|
local bypass_query_cache="1"
|
|
3295
3349
|
|
|
@@ -3299,13 +3353,14 @@ build_dynamic_reload_command() {
|
|
|
3299
3353
|
script_path="$(pwd)/${script_path}"
|
|
3300
3354
|
fi
|
|
3301
3355
|
|
|
3302
|
-
printf 'FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE=%s FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_FALLBACK_FILE=%q %q --dynamic-reload -- "{q}"' "${bypass_query_cache}" "${manager_override}" "${fallback_file}" "${script_path}"
|
|
3356
|
+
printf 'FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE=%s FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_MANAGER_LIST=%q FPF_IPC_FALLBACK_FILE=%q %q --dynamic-reload -- "{q}"' "${bypass_query_cache}" "${manager_override}" "${manager_list_csv}" "${fallback_file}" "${script_path}"
|
|
3303
3357
|
}
|
|
3304
3358
|
|
|
3305
3359
|
build_dynamic_reload_command_for_query() {
|
|
3306
3360
|
local manager_override="$1"
|
|
3307
3361
|
local fallback_file="$2"
|
|
3308
|
-
local
|
|
3362
|
+
local manager_list_csv="$3"
|
|
3363
|
+
local query_value="$4"
|
|
3309
3364
|
local script_path="${BASH_SOURCE[0]}"
|
|
3310
3365
|
local bypass_query_cache="1"
|
|
3311
3366
|
|
|
@@ -3315,31 +3370,33 @@ build_dynamic_reload_command_for_query() {
|
|
|
3315
3370
|
script_path="$(pwd)/${script_path}"
|
|
3316
3371
|
fi
|
|
3317
3372
|
|
|
3318
|
-
printf 'FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE=%s FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_FALLBACK_FILE=%q %q --dynamic-reload -- %q' "${bypass_query_cache}" "${manager_override}" "${fallback_file}" "${script_path}" "${query_value}"
|
|
3373
|
+
printf 'FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE=%s FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_MANAGER_LIST=%q FPF_IPC_FALLBACK_FILE=%q %q --dynamic-reload -- %q' "${bypass_query_cache}" "${manager_override}" "${manager_list_csv}" "${fallback_file}" "${script_path}" "${query_value}"
|
|
3319
3374
|
}
|
|
3320
3375
|
|
|
3321
3376
|
build_dynamic_reload_ipc_command() {
|
|
3322
3377
|
local manager_override="$1"
|
|
3323
3378
|
local fallback_file="$2"
|
|
3379
|
+
local manager_list_csv="${3:-}"
|
|
3324
3380
|
local script_path="${BASH_SOURCE[0]}"
|
|
3325
3381
|
|
|
3326
3382
|
if [[ "${script_path}" != /* ]]; then
|
|
3327
3383
|
script_path="$(pwd)/${script_path}"
|
|
3328
3384
|
fi
|
|
3329
3385
|
|
|
3330
|
-
printf 'FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_FALLBACK_FILE=%q %q --ipc-reload -- "{q}"' "${manager_override}" "${fallback_file}" "${script_path}"
|
|
3386
|
+
printf 'FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_MANAGER_LIST=%q FPF_IPC_FALLBACK_FILE=%q %q --ipc-reload -- "{q}"' "${manager_override}" "${manager_list_csv}" "${fallback_file}" "${script_path}"
|
|
3331
3387
|
}
|
|
3332
3388
|
|
|
3333
3389
|
build_dynamic_query_notify_ipc_command() {
|
|
3334
3390
|
local manager_override="$1"
|
|
3335
3391
|
local fallback_file="$2"
|
|
3392
|
+
local manager_list_csv="${3:-}"
|
|
3336
3393
|
local script_path="${BASH_SOURCE[0]}"
|
|
3337
3394
|
|
|
3338
3395
|
if [[ "${script_path}" != /* ]]; then
|
|
3339
3396
|
script_path="$(pwd)/${script_path}"
|
|
3340
3397
|
fi
|
|
3341
3398
|
|
|
3342
|
-
printf 'FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_FALLBACK_FILE=%q %q --ipc-query-notify -- "{q}"' "${manager_override}" "${fallback_file}" "${script_path}"
|
|
3399
|
+
printf 'FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_MANAGER_LIST=%q FPF_IPC_FALLBACK_FILE=%q %q --ipc-query-notify -- "{q}"' "${manager_override}" "${manager_list_csv}" "${fallback_file}" "${script_path}"
|
|
3343
3400
|
}
|
|
3344
3401
|
|
|
3345
3402
|
fzf_supports_listen() {
|
|
@@ -3444,11 +3501,15 @@ send_fzf_prompt_action() {
|
|
|
3444
3501
|
run_dynamic_reload_action() {
|
|
3445
3502
|
local query="$1"
|
|
3446
3503
|
local manager_override="${FPF_IPC_MANAGER_OVERRIDE:-}"
|
|
3504
|
+
local manager_list_csv="${FPF_IPC_MANAGER_LIST:-}"
|
|
3447
3505
|
local fallback_file="${FPF_IPC_FALLBACK_FILE:-}"
|
|
3448
3506
|
local min_chars="${FPF_RELOAD_MIN_CHARS:-2}"
|
|
3449
3507
|
local reload_debounce="${FPF_RELOAD_DEBOUNCE:-0.12}"
|
|
3450
3508
|
local output_file=""
|
|
3451
3509
|
local detected_manager=""
|
|
3510
|
+
local manager_seen=""
|
|
3511
|
+
local manager_entry=""
|
|
3512
|
+
local -a manager_list_entries=()
|
|
3452
3513
|
local -a managers=()
|
|
3453
3514
|
|
|
3454
3515
|
if [[ -z "${fallback_file}" || ! -r "${fallback_file}" ]]; then
|
|
@@ -3477,6 +3538,25 @@ run_dynamic_reload_action() {
|
|
|
3477
3538
|
return 0
|
|
3478
3539
|
fi
|
|
3479
3540
|
managers+=("${manager_override}")
|
|
3541
|
+
elif [[ -n "${manager_list_csv}" ]]; then
|
|
3542
|
+
IFS=',' read -r -a manager_list_entries <<<"${manager_list_csv}"
|
|
3543
|
+
for manager_entry in "${manager_list_entries[@]-}"; do
|
|
3544
|
+
manager_entry="$(trim_whitespace "${manager_entry}")"
|
|
3545
|
+
[[ -n "${manager_entry}" ]] || continue
|
|
3546
|
+
|
|
3547
|
+
detected_manager="$(normalize_manager "${manager_entry}")"
|
|
3548
|
+
if ! manager_supported "${detected_manager}" || ! manager_command_ready "${detected_manager}"; then
|
|
3549
|
+
continue
|
|
3550
|
+
fi
|
|
3551
|
+
|
|
3552
|
+
case " ${manager_seen} " in
|
|
3553
|
+
*" ${detected_manager} "*)
|
|
3554
|
+
continue
|
|
3555
|
+
;;
|
|
3556
|
+
esac
|
|
3557
|
+
manager_seen+=" ${detected_manager}"
|
|
3558
|
+
managers+=("${detected_manager}")
|
|
3559
|
+
done
|
|
3480
3560
|
else
|
|
3481
3561
|
while IFS= read -r detected_manager; do
|
|
3482
3562
|
[[ -n "${detected_manager}" ]] || continue
|
|
@@ -3506,6 +3586,7 @@ run_dynamic_reload_action() {
|
|
|
3506
3586
|
run_ipc_reload_action() {
|
|
3507
3587
|
local query="$1"
|
|
3508
3588
|
local manager_override="${FPF_IPC_MANAGER_OVERRIDE:-}"
|
|
3589
|
+
local manager_list_csv="${FPF_IPC_MANAGER_LIST:-}"
|
|
3509
3590
|
local fallback_file="${FPF_IPC_FALLBACK_FILE:-}"
|
|
3510
3591
|
local reload_command
|
|
3511
3592
|
local action_payload
|
|
@@ -3519,7 +3600,7 @@ run_ipc_reload_action() {
|
|
|
3519
3600
|
manager_supported "${manager_override}" || return 1
|
|
3520
3601
|
fi
|
|
3521
3602
|
|
|
3522
|
-
reload_command="$(build_dynamic_reload_command_for_query "${manager_override}" "${fallback_file}" "${query}")"
|
|
3603
|
+
reload_command="$(build_dynamic_reload_command_for_query "${manager_override}" "${fallback_file}" "${manager_list_csv}" "${query}")"
|
|
3523
3604
|
action_payload="change-prompt(Search> )+reload(${reload_command})"
|
|
3524
3605
|
send_fzf_listen_action "${action_payload}"
|
|
3525
3606
|
}
|
|
@@ -3909,8 +3990,11 @@ main() {
|
|
|
3909
3990
|
local reload_cmd=""
|
|
3910
3991
|
local reload_ipc_cmd=""
|
|
3911
3992
|
local reload_fallback_file="${display_file}"
|
|
3993
|
+
local reload_manager_list=""
|
|
3912
3994
|
if [[ "${ACTION}" == "search" ]]; then
|
|
3913
3995
|
if dynamic_reload_enabled "${#managers[@]}"; then
|
|
3996
|
+
reload_manager_list="$(IFS=,; printf "%s" "${managers[*]-}")"
|
|
3997
|
+
|
|
3914
3998
|
if [[ -n "${query}" ]]; then
|
|
3915
3999
|
reload_fallback_file="$(mktemp "${SESSION_TMP_ROOT}/reload-fallback.XXXXXX")"
|
|
3916
4000
|
loading_progress_begin "${managers[@]-}"
|
|
@@ -3924,9 +4008,9 @@ main() {
|
|
|
3924
4008
|
fi
|
|
3925
4009
|
fi
|
|
3926
4010
|
|
|
3927
|
-
reload_cmd="$(build_dynamic_reload_command "${MANAGER_OVERRIDE}" "${reload_fallback_file}")"
|
|
4011
|
+
reload_cmd="$(build_dynamic_reload_command "${MANAGER_OVERRIDE}" "${reload_fallback_file}" "${reload_manager_list}")"
|
|
3928
4012
|
if dynamic_reload_use_ipc; then
|
|
3929
|
-
reload_ipc_cmd="$(build_dynamic_query_notify_ipc_command "${MANAGER_OVERRIDE}" "${reload_fallback_file}")"
|
|
4013
|
+
reload_ipc_cmd="$(build_dynamic_query_notify_ipc_command "${MANAGER_OVERRIDE}" "${reload_fallback_file}" "${reload_manager_list}")"
|
|
3930
4014
|
fi
|
|
3931
4015
|
fi
|
|
3932
4016
|
fi
|