@optique/core 1.0.15-dev.2873 → 1.0.15-dev.2880

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.
@@ -859,6 +859,8 @@ function ${functionName} () {
859
859
  local __was_sh_glob=0
860
860
  [[ -o sh_glob ]] && __was_sh_glob=1
861
861
  unsetopt sh_glob
862
+ local __was_extended_glob=0
863
+ [[ -o extended_glob ]] && __was_extended_glob=1
862
864
 
863
865
  # Enable glob_dots when hidden files are requested so that
864
866
  # _files and _directories include dot-prefixed entries
@@ -871,7 +873,34 @@ function ${functionName} () {
871
873
  # current word. If the user has already typed beyond the pattern,
872
874
  # keep PREFIX unchanged for incremental narrowing.
873
875
  local __saved_prefix="\$PREFIX"
874
- if [[ -n "\$pattern" ]]; then
876
+ local __initial_file_pattern="" __initial_directory="" __initial_leaf=""
877
+ if [[ ( "\$type" == "file" || "\$type" == "any" || "\$type" == "directory" ) &&
878
+ -z "\$current\$PREFIX\$SUFFIX" &&
879
+ -z "\${compstate[pattern_match]}" &&
880
+ "\$pattern" != /* && "\$pattern" != "~"* ]]; then
881
+ if [[ "\$pattern" == */* ]]; then
882
+ __initial_directory="\${pattern%/*}/"
883
+ fi
884
+ __initial_leaf="\${pattern##*/}"
885
+ # Native -g filters are split as shell words and use extended glob
886
+ # syntax. Keep unsupported filename forms on the existing path.
887
+ if [[ "\$__initial_leaf" == *[\*\?]* &&
888
+ "\$__initial_directory" != *[\*\?]* &&
889
+ "\$__initial_directory" != *["[]()"]* &&
890
+ "\$__initial_leaf" != *["[]"]* &&
891
+ "\$__initial_leaf" != *'\\'* &&
892
+ "\$__initial_leaf" != *[[:space:]]* &&
893
+ "\$__initial_leaf" != *["#~^()|<>;&"]* &&
894
+ "\$__initial_leaf" != *"'"* && "\$__initial_leaf" != *'"'* ]]; then
895
+ __initial_file_pattern="\$__initial_leaf"
896
+ # Only the literal directory belongs in PREFIX. Quote it so
897
+ # spaces and shell metacharacters remain literal path text.
898
+ if [[ -n "\$__initial_directory" ]]; then
899
+ PREFIX="\${(q)__initial_directory}"
900
+ fi
901
+ fi
902
+ fi
903
+ if [[ -n "\$pattern" && -z "\$__initial_file_pattern" ]]; then
875
904
  # Normalize leading ./ so that ./src/ma matches pattern src/
876
905
  local __norm_prefix="\${PREFIX#./}"
877
906
  local __norm_pattern="\${pattern#./}"
@@ -896,69 +925,83 @@ function ${functionName} () {
896
925
  ext_pattern="*.\$extensions"
897
926
  fi
898
927
  fi
928
+ # _wanted/_next_label write to the named explanation parameter.
929
+ # Keep it local for every file directive, including directory/any.
930
+ local -a expl=()
899
931
  # Use zsh's native file completion
900
932
  case "\$type" in
901
- file)
902
- # Use the same regular-file filter with or without extensions,
903
- # keeping symlinked files and directory navigation available.
904
- local file_pattern="\${ext_pattern:-*}(#q-.)"
905
- local file_subtree_pattern="**/*(#q/N)"
906
- local -a expl=() file_subtree=() file_recursive_patterns=()
907
- local -a file_tags=(files directories)
908
- local file_recursive_pattern file_directory file_prefix file_tag
909
- if [[ -z "\$ext_pattern" ]] &&
910
- zstyle -t ":completion:\${curcontext}:" list-dirs-first; then
911
- file_tags=(directories files)
912
- fi
913
- _tags "\${file_tags[@]}"
914
- while _tags; do
915
- local file_matched=0
916
- for file_tag in "\${file_tags[@]}"; do
917
- if [[ "\$file_tag" == directories ]]; then
918
- while _next_label directories expl directory; do
919
- _path_files -/ "\${expl[@]}" && file_matched=1
933
+ file|any)
934
+ if [[ "\$type" == "file" || -n "\$__initial_file_pattern" ]]; then
935
+ # Regular-file suggestions retain symlinked files; initial
936
+ # any globs use a non-directory qualifier instead.
937
+ local file_pattern="\${ext_pattern:-*}(#q-.)"
938
+ if [[ -n "\$__initial_file_pattern" ]]; then
939
+ local __file_qualifier="-."
940
+ [[ "\$type" == "any" ]] && __file_qualifier="^-/"
941
+ local -a __initial_file_patterns=()
942
+ if [[ -n "\$extensions" ]]; then
943
+ setopt extended_glob
944
+ local __initial_extension
945
+ for __initial_extension in "\${(@s:,:)extensions}"; do
946
+ __initial_file_patterns+=("(\${__initial_file_pattern}~^*.\${__initial_extension})(#q\${__file_qualifier})")
920
947
  done
921
948
  else
922
- while _next_label files expl file; do
923
- local -a file_ignore=() file_ignore_args=()
924
- # Explicit globs bypass automatic fignore. Apply it only
925
- # when the tag has not supplied its own ignore patterns.
926
- if [[ -z "\$ext_pattern" && -z "\$_comp_no_ignore" && -n "\$FIGNORE" ]] && (( \${#_comp_ignore[@]} == 0 )); then
927
- file_ignore=("?*\${^fignore[@]}")
928
- file_ignore_args=(-F file_ignore)
929
- fi
930
- if _path_files -g "\${file_pattern}" "\${expl[@]}" "\${file_ignore_args[@]}"; then
931
- file_matched=1
932
- elif [[ -z "\$ext_pattern" && "\$PREFIX\$SUFFIX" != */* ]] &&
933
- zstyle -a ":completion:\${curcontext}:files" recursive-files file_recursive_patterns; then
934
- # Match _files' recursive fallback, retaining the same
935
- # file filter and tag-specific ignore options.
936
- for file_recursive_pattern in "\${file_recursive_patterns[@]}"; do
937
- if [[ "\$PWD/" = \${~file_recursive_pattern} ]]; then
938
- if (( \${#file_subtree[@]} == 0 )); then
939
- file_subtree=(\${~file_subtree_pattern})
940
- fi
941
- for file_directory in "\${file_subtree[@]}"; do
942
- file_prefix="\$PREFIX"
943
- PREFIX="\$file_directory/\$PREFIX"
944
- _path_files -g "\${file_pattern}" "\${expl[@]}" "\${file_ignore_args[@]}" && file_matched=1
945
- PREFIX="\$file_prefix"
946
- done
947
- break
948
- fi
949
- done
950
- fi
951
- done
949
+ __initial_file_patterns=("\${__initial_file_pattern}(#q\${__file_qualifier})")
952
950
  fi
951
+ file_pattern="\${(j: :)__initial_file_patterns}"
952
+ fi
953
+ local file_subtree_pattern="**/*(#q/N)"
954
+ local -a file_subtree=() file_recursive_patterns=()
955
+ local -a file_tags=(files directories)
956
+ local file_recursive_pattern file_directory file_prefix file_tag
957
+ if [[ -n "\$__initial_file_pattern" || -z "\$ext_pattern" ]] &&
958
+ zstyle -t ":completion:\${curcontext}:" list-dirs-first; then
959
+ file_tags=(directories files)
960
+ fi
961
+ _tags "\${file_tags[@]}"
962
+ while _tags; do
963
+ local file_matched=0
964
+ for file_tag in "\${file_tags[@]}"; do
965
+ if [[ "\$file_tag" == directories ]]; then
966
+ while _next_label directories expl directory; do
967
+ _path_files -/ "\${expl[@]}" && file_matched=1
968
+ done
969
+ else
970
+ while _next_label files expl file; do
971
+ local -a file_ignore=() file_ignore_args=()
972
+ # Explicit globs bypass automatic fignore. Apply it only
973
+ # when the tag has not supplied its own ignore patterns.
974
+ if [[ -z "\$__initial_file_pattern" && -z "\$ext_pattern" && -z "\$_comp_no_ignore" && -n "\$FIGNORE" ]] && (( \${#_comp_ignore[@]} == 0 )); then
975
+ file_ignore=("?*\${^fignore[@]}")
976
+ file_ignore_args=(-F file_ignore)
977
+ fi
978
+ if _path_files -g "\${file_pattern}" "\${expl[@]}" "\${file_ignore_args[@]}"; then
979
+ file_matched=1
980
+ elif [[ ( -n "\$__initial_file_pattern" || -z "\$ext_pattern" ) && "\$PREFIX\$SUFFIX" != */* ]] &&
981
+ zstyle -a ":completion:\${curcontext}:files" recursive-files file_recursive_patterns; then
982
+ # Match _files' recursive fallback, retaining the same
983
+ # file filter and tag-specific ignore options.
984
+ for file_recursive_pattern in "\${file_recursive_patterns[@]}"; do
985
+ if [[ "\$PWD/" = \${~file_recursive_pattern} ]]; then
986
+ if (( \${#file_subtree[@]} == 0 )); then
987
+ file_subtree=(\${~file_subtree_pattern})
988
+ fi
989
+ for file_directory in "\${file_subtree[@]}"; do
990
+ file_prefix="\$PREFIX"
991
+ PREFIX="\$file_directory/\$PREFIX"
992
+ _path_files -g "\${file_pattern}" "\${expl[@]}" "\${file_ignore_args[@]}" && file_matched=1
993
+ PREFIX="\$file_prefix"
994
+ done
995
+ break
996
+ fi
997
+ done
998
+ fi
999
+ done
1000
+ fi
1001
+ done
1002
+ (( file_matched )) && break
953
1003
  done
954
- (( file_matched )) && break
955
- done
956
- ;;
957
- directory)
958
- _directories
959
- ;;
960
- any)
961
- if [[ -n "\$ext_pattern" ]]; then
1004
+ elif [[ -n "\$ext_pattern" ]]; then
962
1005
  local file_pattern="\${ext_pattern}(#q^-/)"
963
1006
  _wanted files expl file _path_files -g "\${file_pattern}"
964
1007
  _wanted directories expl directory _path_files -/
@@ -966,10 +1009,18 @@ function ${functionName} () {
966
1009
  _files
967
1010
  fi
968
1011
  ;;
1012
+ directory)
1013
+ if [[ -n "\$__initial_file_pattern" ]]; then
1014
+ # -/ would add every directory alongside the filtered glob.
1015
+ _wanted directories expl directory _path_files -g "\${__initial_file_pattern}(#q-/)"
1016
+ else
1017
+ _directories
1018
+ fi
1019
+ ;;
969
1020
  esac
970
-
971
1021
  # Restore PREFIX and glob_dots to their previous state
972
1022
  PREFIX="\$__saved_prefix"
1023
+ if [[ "\$__was_extended_glob" == "1" ]]; then setopt extended_glob; else unsetopt extended_glob; fi
973
1024
  if [[ "\$__was_sh_glob" == "1" ]]; then setopt sh_glob; else unsetopt sh_glob; fi
974
1025
  if [[ "\$__was_glob_dots" == "1" ]]; then setopt glob_dots; else unsetopt glob_dots; fi
975
1026
  else
@@ -859,6 +859,8 @@ function ${functionName} () {
859
859
  local __was_sh_glob=0
860
860
  [[ -o sh_glob ]] && __was_sh_glob=1
861
861
  unsetopt sh_glob
862
+ local __was_extended_glob=0
863
+ [[ -o extended_glob ]] && __was_extended_glob=1
862
864
 
863
865
  # Enable glob_dots when hidden files are requested so that
864
866
  # _files and _directories include dot-prefixed entries
@@ -871,7 +873,34 @@ function ${functionName} () {
871
873
  # current word. If the user has already typed beyond the pattern,
872
874
  # keep PREFIX unchanged for incremental narrowing.
873
875
  local __saved_prefix="\$PREFIX"
874
- if [[ -n "\$pattern" ]]; then
876
+ local __initial_file_pattern="" __initial_directory="" __initial_leaf=""
877
+ if [[ ( "\$type" == "file" || "\$type" == "any" || "\$type" == "directory" ) &&
878
+ -z "\$current\$PREFIX\$SUFFIX" &&
879
+ -z "\${compstate[pattern_match]}" &&
880
+ "\$pattern" != /* && "\$pattern" != "~"* ]]; then
881
+ if [[ "\$pattern" == */* ]]; then
882
+ __initial_directory="\${pattern%/*}/"
883
+ fi
884
+ __initial_leaf="\${pattern##*/}"
885
+ # Native -g filters are split as shell words and use extended glob
886
+ # syntax. Keep unsupported filename forms on the existing path.
887
+ if [[ "\$__initial_leaf" == *[\*\?]* &&
888
+ "\$__initial_directory" != *[\*\?]* &&
889
+ "\$__initial_directory" != *["[]()"]* &&
890
+ "\$__initial_leaf" != *["[]"]* &&
891
+ "\$__initial_leaf" != *'\\'* &&
892
+ "\$__initial_leaf" != *[[:space:]]* &&
893
+ "\$__initial_leaf" != *["#~^()|<>;&"]* &&
894
+ "\$__initial_leaf" != *"'"* && "\$__initial_leaf" != *'"'* ]]; then
895
+ __initial_file_pattern="\$__initial_leaf"
896
+ # Only the literal directory belongs in PREFIX. Quote it so
897
+ # spaces and shell metacharacters remain literal path text.
898
+ if [[ -n "\$__initial_directory" ]]; then
899
+ PREFIX="\${(q)__initial_directory}"
900
+ fi
901
+ fi
902
+ fi
903
+ if [[ -n "\$pattern" && -z "\$__initial_file_pattern" ]]; then
875
904
  # Normalize leading ./ so that ./src/ma matches pattern src/
876
905
  local __norm_prefix="\${PREFIX#./}"
877
906
  local __norm_pattern="\${pattern#./}"
@@ -896,69 +925,83 @@ function ${functionName} () {
896
925
  ext_pattern="*.\$extensions"
897
926
  fi
898
927
  fi
928
+ # _wanted/_next_label write to the named explanation parameter.
929
+ # Keep it local for every file directive, including directory/any.
930
+ local -a expl=()
899
931
  # Use zsh's native file completion
900
932
  case "\$type" in
901
- file)
902
- # Use the same regular-file filter with or without extensions,
903
- # keeping symlinked files and directory navigation available.
904
- local file_pattern="\${ext_pattern:-*}(#q-.)"
905
- local file_subtree_pattern="**/*(#q/N)"
906
- local -a expl=() file_subtree=() file_recursive_patterns=()
907
- local -a file_tags=(files directories)
908
- local file_recursive_pattern file_directory file_prefix file_tag
909
- if [[ -z "\$ext_pattern" ]] &&
910
- zstyle -t ":completion:\${curcontext}:" list-dirs-first; then
911
- file_tags=(directories files)
912
- fi
913
- _tags "\${file_tags[@]}"
914
- while _tags; do
915
- local file_matched=0
916
- for file_tag in "\${file_tags[@]}"; do
917
- if [[ "\$file_tag" == directories ]]; then
918
- while _next_label directories expl directory; do
919
- _path_files -/ "\${expl[@]}" && file_matched=1
933
+ file|any)
934
+ if [[ "\$type" == "file" || -n "\$__initial_file_pattern" ]]; then
935
+ # Regular-file suggestions retain symlinked files; initial
936
+ # any globs use a non-directory qualifier instead.
937
+ local file_pattern="\${ext_pattern:-*}(#q-.)"
938
+ if [[ -n "\$__initial_file_pattern" ]]; then
939
+ local __file_qualifier="-."
940
+ [[ "\$type" == "any" ]] && __file_qualifier="^-/"
941
+ local -a __initial_file_patterns=()
942
+ if [[ -n "\$extensions" ]]; then
943
+ setopt extended_glob
944
+ local __initial_extension
945
+ for __initial_extension in "\${(@s:,:)extensions}"; do
946
+ __initial_file_patterns+=("(\${__initial_file_pattern}~^*.\${__initial_extension})(#q\${__file_qualifier})")
920
947
  done
921
948
  else
922
- while _next_label files expl file; do
923
- local -a file_ignore=() file_ignore_args=()
924
- # Explicit globs bypass automatic fignore. Apply it only
925
- # when the tag has not supplied its own ignore patterns.
926
- if [[ -z "\$ext_pattern" && -z "\$_comp_no_ignore" && -n "\$FIGNORE" ]] && (( \${#_comp_ignore[@]} == 0 )); then
927
- file_ignore=("?*\${^fignore[@]}")
928
- file_ignore_args=(-F file_ignore)
929
- fi
930
- if _path_files -g "\${file_pattern}" "\${expl[@]}" "\${file_ignore_args[@]}"; then
931
- file_matched=1
932
- elif [[ -z "\$ext_pattern" && "\$PREFIX\$SUFFIX" != */* ]] &&
933
- zstyle -a ":completion:\${curcontext}:files" recursive-files file_recursive_patterns; then
934
- # Match _files' recursive fallback, retaining the same
935
- # file filter and tag-specific ignore options.
936
- for file_recursive_pattern in "\${file_recursive_patterns[@]}"; do
937
- if [[ "\$PWD/" = \${~file_recursive_pattern} ]]; then
938
- if (( \${#file_subtree[@]} == 0 )); then
939
- file_subtree=(\${~file_subtree_pattern})
940
- fi
941
- for file_directory in "\${file_subtree[@]}"; do
942
- file_prefix="\$PREFIX"
943
- PREFIX="\$file_directory/\$PREFIX"
944
- _path_files -g "\${file_pattern}" "\${expl[@]}" "\${file_ignore_args[@]}" && file_matched=1
945
- PREFIX="\$file_prefix"
946
- done
947
- break
948
- fi
949
- done
950
- fi
951
- done
949
+ __initial_file_patterns=("\${__initial_file_pattern}(#q\${__file_qualifier})")
952
950
  fi
951
+ file_pattern="\${(j: :)__initial_file_patterns}"
952
+ fi
953
+ local file_subtree_pattern="**/*(#q/N)"
954
+ local -a file_subtree=() file_recursive_patterns=()
955
+ local -a file_tags=(files directories)
956
+ local file_recursive_pattern file_directory file_prefix file_tag
957
+ if [[ -n "\$__initial_file_pattern" || -z "\$ext_pattern" ]] &&
958
+ zstyle -t ":completion:\${curcontext}:" list-dirs-first; then
959
+ file_tags=(directories files)
960
+ fi
961
+ _tags "\${file_tags[@]}"
962
+ while _tags; do
963
+ local file_matched=0
964
+ for file_tag in "\${file_tags[@]}"; do
965
+ if [[ "\$file_tag" == directories ]]; then
966
+ while _next_label directories expl directory; do
967
+ _path_files -/ "\${expl[@]}" && file_matched=1
968
+ done
969
+ else
970
+ while _next_label files expl file; do
971
+ local -a file_ignore=() file_ignore_args=()
972
+ # Explicit globs bypass automatic fignore. Apply it only
973
+ # when the tag has not supplied its own ignore patterns.
974
+ if [[ -z "\$__initial_file_pattern" && -z "\$ext_pattern" && -z "\$_comp_no_ignore" && -n "\$FIGNORE" ]] && (( \${#_comp_ignore[@]} == 0 )); then
975
+ file_ignore=("?*\${^fignore[@]}")
976
+ file_ignore_args=(-F file_ignore)
977
+ fi
978
+ if _path_files -g "\${file_pattern}" "\${expl[@]}" "\${file_ignore_args[@]}"; then
979
+ file_matched=1
980
+ elif [[ ( -n "\$__initial_file_pattern" || -z "\$ext_pattern" ) && "\$PREFIX\$SUFFIX" != */* ]] &&
981
+ zstyle -a ":completion:\${curcontext}:files" recursive-files file_recursive_patterns; then
982
+ # Match _files' recursive fallback, retaining the same
983
+ # file filter and tag-specific ignore options.
984
+ for file_recursive_pattern in "\${file_recursive_patterns[@]}"; do
985
+ if [[ "\$PWD/" = \${~file_recursive_pattern} ]]; then
986
+ if (( \${#file_subtree[@]} == 0 )); then
987
+ file_subtree=(\${~file_subtree_pattern})
988
+ fi
989
+ for file_directory in "\${file_subtree[@]}"; do
990
+ file_prefix="\$PREFIX"
991
+ PREFIX="\$file_directory/\$PREFIX"
992
+ _path_files -g "\${file_pattern}" "\${expl[@]}" "\${file_ignore_args[@]}" && file_matched=1
993
+ PREFIX="\$file_prefix"
994
+ done
995
+ break
996
+ fi
997
+ done
998
+ fi
999
+ done
1000
+ fi
1001
+ done
1002
+ (( file_matched )) && break
953
1003
  done
954
- (( file_matched )) && break
955
- done
956
- ;;
957
- directory)
958
- _directories
959
- ;;
960
- any)
961
- if [[ -n "\$ext_pattern" ]]; then
1004
+ elif [[ -n "\$ext_pattern" ]]; then
962
1005
  local file_pattern="\${ext_pattern}(#q^-/)"
963
1006
  _wanted files expl file _path_files -g "\${file_pattern}"
964
1007
  _wanted directories expl directory _path_files -/
@@ -966,10 +1009,18 @@ function ${functionName} () {
966
1009
  _files
967
1010
  fi
968
1011
  ;;
1012
+ directory)
1013
+ if [[ -n "\$__initial_file_pattern" ]]; then
1014
+ # -/ would add every directory alongside the filtered glob.
1015
+ _wanted directories expl directory _path_files -g "\${__initial_file_pattern}(#q-/)"
1016
+ else
1017
+ _directories
1018
+ fi
1019
+ ;;
969
1020
  esac
970
-
971
1021
  # Restore PREFIX and glob_dots to their previous state
972
1022
  PREFIX="\$__saved_prefix"
1023
+ if [[ "\$__was_extended_glob" == "1" ]]; then setopt extended_glob; else unsetopt extended_glob; fi
973
1024
  if [[ "\$__was_sh_glob" == "1" ]]; then setopt sh_glob; else unsetopt sh_glob; fi
974
1025
  if [[ "\$__was_glob_dots" == "1" ]]; then setopt glob_dots; else unsetopt glob_dots; fi
975
1026
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.15-dev.2873",
3
+ "version": "1.0.15-dev.2880",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",