@optique/core 1.0.15-dev.2777 → 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.
@@ -1025,8 +1025,10 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
1025
1025
 
1026
1026
  # If the glob base is a directory without a trailing slash (e.g., "src"),
1027
1027
  # append one so that ls enumerates its contents instead of matching
1028
- # siblings like "src-old"
1029
- let glob_base = if ($glob_base | is-not-empty) and ($glob_base | path type) == "dir" and (not ($glob_base | str ends-with "/")) {
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 "/")) {
1030
1032
  $glob_base + "/"
1031
1033
  } else {
1032
1034
  $glob_base
@@ -1055,15 +1057,31 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
1055
1057
  null
1056
1058
  }
1057
1059
 
1058
- # Use ls -a to include hidden files when requested
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
+
1059
1077
  let items = try {
1060
1078
  match $type {
1061
1079
  "file" => {
1062
1080
  if ($extensions | is-empty) {
1063
- (if $hidden { ls -a $ls_pattern } else { ls $ls_pattern }) | where type == file or type == dir
1081
+ (do $list_entries $ls_pattern) | where type == file or type == dir
1064
1082
  } else {
1065
1083
  let ext_list = ($extensions | split row ',' | each {|e| $e | str replace -r '^\\.' '' })
1066
- let all_items = (if $hidden { ls -a $ls_pattern } else { ls $ls_pattern })
1084
+ let all_items = (do $list_entries $ls_pattern)
1067
1085
  let dirs = $all_items | where type == dir
1068
1086
  let files = $all_items | where type == file | where {|f|
1069
1087
  let ext = ($f.name | path parse | get extension)
@@ -1073,14 +1091,14 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
1073
1091
  }
1074
1092
  },
1075
1093
  "directory" => {
1076
- (if $hidden { ls -a $ls_pattern } else { ls $ls_pattern }) | where type == dir
1094
+ (do $list_entries $ls_pattern) | where type == dir
1077
1095
  },
1078
1096
  "any" => {
1079
1097
  if ($extensions | is-empty) {
1080
- if $hidden { ls -a $ls_pattern } else { ls $ls_pattern }
1098
+ do $list_entries $ls_pattern
1081
1099
  } else {
1082
1100
  let ext_list = ($extensions | split row ',' | each {|e| $e | str replace -r '^\\.' '' })
1083
- let all_items = (if $hidden { ls -a $ls_pattern } else { ls $ls_pattern })
1101
+ let all_items = (do $list_entries $ls_pattern)
1084
1102
  let dirs = $all_items | where type == dir
1085
1103
  let files = $all_items | where type == file | where {|f|
1086
1104
  let ext = ($f.name | path parse | get extension)
@@ -1099,7 +1117,7 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
1099
1117
  # even when the glob itself does not match directory names)
1100
1118
  let items = if ($glob_dir_pattern != null) and ($type != "directory") {
1101
1119
  let extra_dirs = try {
1102
- (if $hidden { ls -a $glob_dir_pattern } else { ls $glob_dir_pattern }) | where type == dir
1120
+ (do $list_entries $glob_dir_pattern) | where type == dir
1103
1121
  } catch {
1104
1122
  []
1105
1123
  }
@@ -1025,8 +1025,10 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
1025
1025
 
1026
1026
  # If the glob base is a directory without a trailing slash (e.g., "src"),
1027
1027
  # append one so that ls enumerates its contents instead of matching
1028
- # siblings like "src-old"
1029
- let glob_base = if ($glob_base | is-not-empty) and ($glob_base | path type) == "dir" and (not ($glob_base | str ends-with "/")) {
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 "/")) {
1030
1032
  $glob_base + "/"
1031
1033
  } else {
1032
1034
  $glob_base
@@ -1055,15 +1057,31 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
1055
1057
  null
1056
1058
  }
1057
1059
 
1058
- # Use ls -a to include hidden files when requested
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
+
1059
1077
  let items = try {
1060
1078
  match $type {
1061
1079
  "file" => {
1062
1080
  if ($extensions | is-empty) {
1063
- (if $hidden { ls -a $ls_pattern } else { ls $ls_pattern }) | where type == file or type == dir
1081
+ (do $list_entries $ls_pattern) | where type == file or type == dir
1064
1082
  } else {
1065
1083
  let ext_list = ($extensions | split row ',' | each {|e| $e | str replace -r '^\\.' '' })
1066
- let all_items = (if $hidden { ls -a $ls_pattern } else { ls $ls_pattern })
1084
+ let all_items = (do $list_entries $ls_pattern)
1067
1085
  let dirs = $all_items | where type == dir
1068
1086
  let files = $all_items | where type == file | where {|f|
1069
1087
  let ext = ($f.name | path parse | get extension)
@@ -1073,14 +1091,14 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
1073
1091
  }
1074
1092
  },
1075
1093
  "directory" => {
1076
- (if $hidden { ls -a $ls_pattern } else { ls $ls_pattern }) | where type == dir
1094
+ (do $list_entries $ls_pattern) | where type == dir
1077
1095
  },
1078
1096
  "any" => {
1079
1097
  if ($extensions | is-empty) {
1080
- if $hidden { ls -a $ls_pattern } else { ls $ls_pattern }
1098
+ do $list_entries $ls_pattern
1081
1099
  } else {
1082
1100
  let ext_list = ($extensions | split row ',' | each {|e| $e | str replace -r '^\\.' '' })
1083
- let all_items = (if $hidden { ls -a $ls_pattern } else { ls $ls_pattern })
1101
+ let all_items = (do $list_entries $ls_pattern)
1084
1102
  let dirs = $all_items | where type == dir
1085
1103
  let files = $all_items | where type == file | where {|f|
1086
1104
  let ext = ($f.name | path parse | get extension)
@@ -1099,7 +1117,7 @@ ${escapedArgs ? ` ^${programName} ${escapedArgs} ...$final_args | complete |
1099
1117
  # even when the glob itself does not match directory names)
1100
1118
  let items = if ($glob_dir_pattern != null) and ($type != "directory") {
1101
1119
  let extra_dirs = try {
1102
- (if $hidden { ls -a $glob_dir_pattern } else { ls $glob_dir_pattern }) | where type == dir
1120
+ (do $list_entries $glob_dir_pattern) | where type == dir
1103
1121
  } catch {
1104
1122
  []
1105
1123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.15-dev.2777",
3
+ "version": "1.0.15-dev.2784",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",