@optique/core 1.0.15-dev.2764 → 1.0.15-dev.2784
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/dist/completion.cjs +35 -16
- package/dist/completion.js +35 -16
- package/package.json +1 -1
package/dist/completion.cjs
CHANGED
|
@@ -695,8 +695,8 @@ ${escapedArgs ? ` set -l output (${programName} ${escapedArgs} $prev $current
|
|
|
695
695
|
# dotfiles, so also scan .* when the filter targets them.
|
|
696
696
|
for __item in $__glob_dir/*
|
|
697
697
|
if test -e "$__item"
|
|
698
|
-
set -l __bn (basename "$__item")
|
|
699
|
-
if string match -q "$__glob_filter"
|
|
698
|
+
set -l __bn (basename -- "$__item")
|
|
699
|
+
if string match -q -- "$__glob_filter" "$__bn"
|
|
700
700
|
set -a __candidates "$__item"
|
|
701
701
|
end
|
|
702
702
|
end
|
|
@@ -704,11 +704,11 @@ ${escapedArgs ? ` set -l output (${programName} ${escapedArgs} $prev $current
|
|
|
704
704
|
if string match -q '.*' -- "$__glob_filter"
|
|
705
705
|
for __item in $__glob_dir/.*
|
|
706
706
|
if test -e "$__item"
|
|
707
|
-
set -l __bn (basename "$__item")
|
|
707
|
+
set -l __bn (basename -- "$__item")
|
|
708
708
|
if test "$__bn" = "." -o "$__bn" = ".."
|
|
709
709
|
continue
|
|
710
710
|
end
|
|
711
|
-
if string match -q "$__glob_filter"
|
|
711
|
+
if string match -q -- "$__glob_filter" "$__bn"
|
|
712
712
|
set -a __candidates "$__item"
|
|
713
713
|
end
|
|
714
714
|
end
|
|
@@ -822,7 +822,7 @@ ${escapedArgs ? ` set -l output (${programName} ${escapedArgs} $prev $current
|
|
|
822
822
|
if test "$hidden" != "1" -a (string sub -l 1 -- $__glob_basename) != "."
|
|
823
823
|
set -l filtered
|
|
824
824
|
for item in $items
|
|
825
|
-
set -l basename (basename $item)
|
|
825
|
+
set -l basename (basename -- "$item")
|
|
826
826
|
if not string match -q '.*' -- $basename
|
|
827
827
|
set -a filtered $item
|
|
828
828
|
end
|
|
@@ -839,9 +839,10 @@ ${escapedArgs ? ` set -l output (${programName} ${escapedArgs} $prev $current
|
|
|
839
839
|
set items $restored
|
|
840
840
|
end
|
|
841
841
|
|
|
842
|
-
# Output file completions
|
|
842
|
+
# Output file completions. Use printf rather than echo, which
|
|
843
|
+
# would take filenames like -n or -e as its own options.
|
|
843
844
|
for item in $items
|
|
844
|
-
|
|
845
|
+
printf '%s\\n' $item
|
|
845
846
|
end
|
|
846
847
|
else
|
|
847
848
|
# Regular literal completion - split by tab
|
|
@@ -1024,8 +1025,10 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
|
|
|
1024
1025
|
|
|
1025
1026
|
# If the glob base is a directory without a trailing slash (e.g., "src"),
|
|
1026
1027
|
# append one so that ls enumerates its contents instead of matching
|
|
1027
|
-
# siblings like "src-old"
|
|
1028
|
-
|
|
1028
|
+
# siblings like "src-old". path expand follows symlinks, so that
|
|
1029
|
+
# a symlink to a directory is treated the same way; --no-symlink first
|
|
1030
|
+
# resolves .. against the logical $env.PWD as ls does
|
|
1031
|
+
let glob_base = if ($glob_base | is-not-empty) and ($glob_base | path expand --no-symlink | path expand | path type) == "dir" and (not ($glob_base | str ends-with "/")) {
|
|
1029
1032
|
$glob_base + "/"
|
|
1030
1033
|
} else {
|
|
1031
1034
|
$glob_base
|
|
@@ -1054,15 +1057,31 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
|
|
|
1054
1057
|
null
|
|
1055
1058
|
}
|
|
1056
1059
|
|
|
1057
|
-
#
|
|
1060
|
+
# List entries matching a pattern, using ls -a to include hidden
|
|
1061
|
+
# files when requested. ls reports every symlink as type "symlink",
|
|
1062
|
+
# so classify each one by its target's type instead (path expand
|
|
1063
|
+
# follows symlinks); broken or looping symlinks stay "symlink".
|
|
1064
|
+
# Join the name to $env.PWD first so that a leading ~ in an entry
|
|
1065
|
+
# name is not expanded to a home directory, and resolve .. against
|
|
1066
|
+
# the logical $env.PWD (--no-symlink) before following the symlink
|
|
1067
|
+
let list_entries = {|pattern|
|
|
1068
|
+
(if $hidden { ls -a $pattern } else { ls $pattern }) | each {|item|
|
|
1069
|
+
if $item.type == symlink {
|
|
1070
|
+
$item | update type ($env.PWD | path join $item.name | path expand --no-symlink | path expand | path type)
|
|
1071
|
+
} else {
|
|
1072
|
+
$item
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1058
1077
|
let items = try {
|
|
1059
1078
|
match $type {
|
|
1060
1079
|
"file" => {
|
|
1061
1080
|
if ($extensions | is-empty) {
|
|
1062
|
-
(
|
|
1081
|
+
(do $list_entries $ls_pattern) | where type == file or type == dir
|
|
1063
1082
|
} else {
|
|
1064
1083
|
let ext_list = ($extensions | split row ',' | each {|e| $e | str replace -r '^\\.' '' })
|
|
1065
|
-
let all_items = (
|
|
1084
|
+
let all_items = (do $list_entries $ls_pattern)
|
|
1066
1085
|
let dirs = $all_items | where type == dir
|
|
1067
1086
|
let files = $all_items | where type == file | where {|f|
|
|
1068
1087
|
let ext = ($f.name | path parse | get extension)
|
|
@@ -1072,14 +1091,14 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
|
|
|
1072
1091
|
}
|
|
1073
1092
|
},
|
|
1074
1093
|
"directory" => {
|
|
1075
|
-
(
|
|
1094
|
+
(do $list_entries $ls_pattern) | where type == dir
|
|
1076
1095
|
},
|
|
1077
1096
|
"any" => {
|
|
1078
1097
|
if ($extensions | is-empty) {
|
|
1079
|
-
|
|
1098
|
+
do $list_entries $ls_pattern
|
|
1080
1099
|
} else {
|
|
1081
1100
|
let ext_list = ($extensions | split row ',' | each {|e| $e | str replace -r '^\\.' '' })
|
|
1082
|
-
let all_items = (
|
|
1101
|
+
let all_items = (do $list_entries $ls_pattern)
|
|
1083
1102
|
let dirs = $all_items | where type == dir
|
|
1084
1103
|
let files = $all_items | where type == file | where {|f|
|
|
1085
1104
|
let ext = ($f.name | path parse | get extension)
|
|
@@ -1098,7 +1117,7 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
|
|
|
1098
1117
|
# even when the glob itself does not match directory names)
|
|
1099
1118
|
let items = if ($glob_dir_pattern != null) and ($type != "directory") {
|
|
1100
1119
|
let extra_dirs = try {
|
|
1101
|
-
(
|
|
1120
|
+
(do $list_entries $glob_dir_pattern) | where type == dir
|
|
1102
1121
|
} catch {
|
|
1103
1122
|
[]
|
|
1104
1123
|
}
|
package/dist/completion.js
CHANGED
|
@@ -695,8 +695,8 @@ ${escapedArgs ? ` set -l output (${programName} ${escapedArgs} $prev $current
|
|
|
695
695
|
# dotfiles, so also scan .* when the filter targets them.
|
|
696
696
|
for __item in $__glob_dir/*
|
|
697
697
|
if test -e "$__item"
|
|
698
|
-
set -l __bn (basename "$__item")
|
|
699
|
-
if string match -q "$__glob_filter"
|
|
698
|
+
set -l __bn (basename -- "$__item")
|
|
699
|
+
if string match -q -- "$__glob_filter" "$__bn"
|
|
700
700
|
set -a __candidates "$__item"
|
|
701
701
|
end
|
|
702
702
|
end
|
|
@@ -704,11 +704,11 @@ ${escapedArgs ? ` set -l output (${programName} ${escapedArgs} $prev $current
|
|
|
704
704
|
if string match -q '.*' -- "$__glob_filter"
|
|
705
705
|
for __item in $__glob_dir/.*
|
|
706
706
|
if test -e "$__item"
|
|
707
|
-
set -l __bn (basename "$__item")
|
|
707
|
+
set -l __bn (basename -- "$__item")
|
|
708
708
|
if test "$__bn" = "." -o "$__bn" = ".."
|
|
709
709
|
continue
|
|
710
710
|
end
|
|
711
|
-
if string match -q "$__glob_filter"
|
|
711
|
+
if string match -q -- "$__glob_filter" "$__bn"
|
|
712
712
|
set -a __candidates "$__item"
|
|
713
713
|
end
|
|
714
714
|
end
|
|
@@ -822,7 +822,7 @@ ${escapedArgs ? ` set -l output (${programName} ${escapedArgs} $prev $current
|
|
|
822
822
|
if test "$hidden" != "1" -a (string sub -l 1 -- $__glob_basename) != "."
|
|
823
823
|
set -l filtered
|
|
824
824
|
for item in $items
|
|
825
|
-
set -l basename (basename $item)
|
|
825
|
+
set -l basename (basename -- "$item")
|
|
826
826
|
if not string match -q '.*' -- $basename
|
|
827
827
|
set -a filtered $item
|
|
828
828
|
end
|
|
@@ -839,9 +839,10 @@ ${escapedArgs ? ` set -l output (${programName} ${escapedArgs} $prev $current
|
|
|
839
839
|
set items $restored
|
|
840
840
|
end
|
|
841
841
|
|
|
842
|
-
# Output file completions
|
|
842
|
+
# Output file completions. Use printf rather than echo, which
|
|
843
|
+
# would take filenames like -n or -e as its own options.
|
|
843
844
|
for item in $items
|
|
844
|
-
|
|
845
|
+
printf '%s\\n' $item
|
|
845
846
|
end
|
|
846
847
|
else
|
|
847
848
|
# Regular literal completion - split by tab
|
|
@@ -1024,8 +1025,10 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
|
|
|
1024
1025
|
|
|
1025
1026
|
# If the glob base is a directory without a trailing slash (e.g., "src"),
|
|
1026
1027
|
# append one so that ls enumerates its contents instead of matching
|
|
1027
|
-
# siblings like "src-old"
|
|
1028
|
-
|
|
1028
|
+
# siblings like "src-old". path expand follows symlinks, so that
|
|
1029
|
+
# a symlink to a directory is treated the same way; --no-symlink first
|
|
1030
|
+
# resolves .. against the logical $env.PWD as ls does
|
|
1031
|
+
let glob_base = if ($glob_base | is-not-empty) and ($glob_base | path expand --no-symlink | path expand | path type) == "dir" and (not ($glob_base | str ends-with "/")) {
|
|
1029
1032
|
$glob_base + "/"
|
|
1030
1033
|
} else {
|
|
1031
1034
|
$glob_base
|
|
@@ -1054,15 +1057,31 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
|
|
|
1054
1057
|
null
|
|
1055
1058
|
}
|
|
1056
1059
|
|
|
1057
|
-
#
|
|
1060
|
+
# List entries matching a pattern, using ls -a to include hidden
|
|
1061
|
+
# files when requested. ls reports every symlink as type "symlink",
|
|
1062
|
+
# so classify each one by its target's type instead (path expand
|
|
1063
|
+
# follows symlinks); broken or looping symlinks stay "symlink".
|
|
1064
|
+
# Join the name to $env.PWD first so that a leading ~ in an entry
|
|
1065
|
+
# name is not expanded to a home directory, and resolve .. against
|
|
1066
|
+
# the logical $env.PWD (--no-symlink) before following the symlink
|
|
1067
|
+
let list_entries = {|pattern|
|
|
1068
|
+
(if $hidden { ls -a $pattern } else { ls $pattern }) | each {|item|
|
|
1069
|
+
if $item.type == symlink {
|
|
1070
|
+
$item | update type ($env.PWD | path join $item.name | path expand --no-symlink | path expand | path type)
|
|
1071
|
+
} else {
|
|
1072
|
+
$item
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1058
1077
|
let items = try {
|
|
1059
1078
|
match $type {
|
|
1060
1079
|
"file" => {
|
|
1061
1080
|
if ($extensions | is-empty) {
|
|
1062
|
-
(
|
|
1081
|
+
(do $list_entries $ls_pattern) | where type == file or type == dir
|
|
1063
1082
|
} else {
|
|
1064
1083
|
let ext_list = ($extensions | split row ',' | each {|e| $e | str replace -r '^\\.' '' })
|
|
1065
|
-
let all_items = (
|
|
1084
|
+
let all_items = (do $list_entries $ls_pattern)
|
|
1066
1085
|
let dirs = $all_items | where type == dir
|
|
1067
1086
|
let files = $all_items | where type == file | where {|f|
|
|
1068
1087
|
let ext = ($f.name | path parse | get extension)
|
|
@@ -1072,14 +1091,14 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
|
|
|
1072
1091
|
}
|
|
1073
1092
|
},
|
|
1074
1093
|
"directory" => {
|
|
1075
|
-
(
|
|
1094
|
+
(do $list_entries $ls_pattern) | where type == dir
|
|
1076
1095
|
},
|
|
1077
1096
|
"any" => {
|
|
1078
1097
|
if ($extensions | is-empty) {
|
|
1079
|
-
|
|
1098
|
+
do $list_entries $ls_pattern
|
|
1080
1099
|
} else {
|
|
1081
1100
|
let ext_list = ($extensions | split row ',' | each {|e| $e | str replace -r '^\\.' '' })
|
|
1082
|
-
let all_items = (
|
|
1101
|
+
let all_items = (do $list_entries $ls_pattern)
|
|
1083
1102
|
let dirs = $all_items | where type == dir
|
|
1084
1103
|
let files = $all_items | where type == file | where {|f|
|
|
1085
1104
|
let ext = ($f.name | path parse | get extension)
|
|
@@ -1098,7 +1117,7 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
|
|
|
1098
1117
|
# even when the glob itself does not match directory names)
|
|
1099
1118
|
let items = if ($glob_dir_pattern != null) and ($type != "directory") {
|
|
1100
1119
|
let extra_dirs = try {
|
|
1101
|
-
(
|
|
1120
|
+
(do $list_entries $glob_dir_pattern) | where type == dir
|
|
1102
1121
|
} catch {
|
|
1103
1122
|
[]
|
|
1104
1123
|
}
|