fpf-cli 1.6.16 → 1.6.17

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.
Files changed (2) hide show
  1. package/fpf +110 -5
  2. 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.16"
6
+ SCRIPT_VERSION="1.6.17"
7
7
  TMP_ROOT="${TMPDIR:-/tmp}/fpf"
8
8
  SESSION_TMP_ROOT=""
9
9
  HELP_FILE=""
@@ -804,6 +804,109 @@ flatpak_has_any_remotes() {
804
804
  return 1
805
805
  }
806
806
 
807
+ winget_has_default_source() {
808
+ if ! manager_command_ready winget; then
809
+ return 1
810
+ fi
811
+
812
+ if winget source list 2>/dev/null | awk '
813
+ {
814
+ line=$0
815
+ sub(/^[[:space:]]+/, "", line)
816
+ if (line == "") {
817
+ next
818
+ }
819
+ split(line, cols, /[[:space:]]+/)
820
+ if (tolower(cols[1]) == "winget") {
821
+ found=1
822
+ exit
823
+ }
824
+ }
825
+ END { exit (found ? 0 : 1) }
826
+ '; then
827
+ return 0
828
+ fi
829
+
830
+ return 1
831
+ }
832
+
833
+ choco_has_any_sources() {
834
+ if ! manager_command_ready choco; then
835
+ return 1
836
+ fi
837
+
838
+ if choco source list --limit-output 2>/dev/null | awk -F'|' 'NF >= 2 && $1 != "" { found=1; exit } END { exit (found ? 0 : 1) }'; then
839
+ return 0
840
+ fi
841
+
842
+ return 1
843
+ }
844
+
845
+ scoop_has_any_buckets() {
846
+ if ! manager_command_ready scoop; then
847
+ return 1
848
+ fi
849
+
850
+ if scoop bucket list 2>/dev/null | awk '
851
+ {
852
+ line=$0
853
+ sub(/^[[:space:]]+/, "", line)
854
+ if (line == "") {
855
+ next
856
+ }
857
+ if (tolower(line) ~ /^name[[:space:]]+/) {
858
+ next
859
+ }
860
+ if (line ~ /^[-[:space:]]+$/) {
861
+ next
862
+ }
863
+ split(line, cols, /[[:space:]]+/)
864
+ if (length(cols[2]) > 0 && (cols[2] ~ /^https?:\/\// || cols[2] ~ /^git@/ || cols[2] ~ /^ssh:\/\// || cols[2] ~ /^file:\/\// || cols[2] ~ /^\//)) {
865
+ found=1
866
+ exit
867
+ }
868
+ }
869
+ END { exit (found ? 0 : 1) }
870
+ '; then
871
+ return 0
872
+ fi
873
+
874
+ return 1
875
+ }
876
+
877
+ manager_no_query_setup_message() {
878
+ local manager="$1"
879
+
880
+ case "${manager}" in
881
+ flatpak)
882
+ if ! flatpak_has_any_remotes; then
883
+ printf "%s" "Flatpak has no remotes configured. Add Flathub with: flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo"
884
+ return 0
885
+ fi
886
+ ;;
887
+ winget)
888
+ if ! winget_has_default_source; then
889
+ printf "%s" "WinGet source 'winget' is not configured. Restore it with: winget source reset --force"
890
+ return 0
891
+ fi
892
+ ;;
893
+ choco)
894
+ if ! choco_has_any_sources; then
895
+ printf "%s" "Chocolatey has no package sources configured. Add the default source with: choco source add -n=chocolatey -s=https://community.chocolatey.org/api/v2/"
896
+ return 0
897
+ fi
898
+ ;;
899
+ scoop)
900
+ if ! scoop_has_any_buckets; then
901
+ printf "%s" "Scoop has no buckets configured. Add the default bucket with: scoop bucket add main"
902
+ return 0
903
+ fi
904
+ ;;
905
+ esac
906
+
907
+ return 1
908
+ }
909
+
807
910
  manager_can_install_fzf() {
808
911
  local manager="$1"
809
912
  case "${manager}" in
@@ -2671,7 +2774,7 @@ run_fuzzy_selector() {
2671
2774
  --bind='focus:transform-preview-label:echo [{1}] {2}')
2672
2775
 
2673
2776
  if [[ -n "${reload_ipc_cmd}" ]]; then
2674
- fzf_args+=(--listen=127.0.0.1:0)
2777
+ fzf_args+=(--listen=0)
2675
2778
  fzf_args+=(--bind="change:execute-silent:${reload_ipc_cmd}")
2676
2779
  if [[ -n "${reload_cmd}" ]]; then
2677
2780
  fzf_args+=(--bind="ctrl-r:reload:${reload_cmd}")
@@ -2863,9 +2966,11 @@ main() {
2863
2966
  if [[ ! -s "${display_file}" ]]; then
2864
2967
  rm -f "${display_file}"
2865
2968
 
2866
- if [[ "${ACTION}" == "search" && "${#managers[@]}" -eq 1 && "${managers[0]}" == "flatpak" ]]; then
2867
- if ! flatpak_has_any_remotes; then
2868
- die "Flatpak has no remotes configured. Add Flathub with: flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo"
2969
+ if [[ "${ACTION}" == "search" && -z "${query}" && "${#managers[@]}" -eq 1 ]]; then
2970
+ local setup_message=""
2971
+ setup_message="$(manager_no_query_setup_message "${managers[0]}" || true)"
2972
+ if [[ -n "${setup_message}" ]]; then
2973
+ die "${setup_message}"
2869
2974
  fi
2870
2975
  fi
2871
2976
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fpf-cli",
3
- "version": "1.6.16",
3
+ "version": "1.6.17",
4
4
  "description": "Cross-platform fuzzy package finder powered by fzf",
5
5
  "bin": {
6
6
  "fpf": "fpf"