mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Expand globs and filepaths (#348)
This commit is contained in:
parent
adb7eeb740
commit
aa7226d5f6
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -945,6 +945,7 @@ name = "nu-parser"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"miette",
|
||||
"nu-path",
|
||||
"nu-plugin",
|
||||
"nu-protocol",
|
||||
"thiserror",
|
||||
|
@ -8,6 +8,7 @@ miette = "3.0.0"
|
||||
thiserror = "1.0.29"
|
||||
nu-protocol = { path = "../nu-protocol"}
|
||||
nu-plugin = { path = "../nu-plugin", optional=true}
|
||||
nu-path = {path = "../nu-path"}
|
||||
|
||||
[features]
|
||||
plugin = ["nu-plugin"]
|
||||
|
@ -1437,9 +1437,11 @@ pub fn parse_filepath(
|
||||
let bytes = trim_quotes(bytes);
|
||||
|
||||
if let Ok(token) = String::from_utf8(bytes.into()) {
|
||||
let filepath = nu_path::expand_path(token);
|
||||
let filepath = filepath.to_string_lossy().to_string();
|
||||
(
|
||||
Expression {
|
||||
expr: Expr::Filepath(token),
|
||||
expr: Expr::Filepath(filepath),
|
||||
span,
|
||||
ty: Type::String,
|
||||
custom_completion: None,
|
||||
@ -1449,7 +1451,7 @@ pub fn parse_filepath(
|
||||
} else {
|
||||
(
|
||||
garbage(span),
|
||||
Some(ParseError::Expected("string".into(), span)),
|
||||
Some(ParseError::Expected("filepath".into(), span)),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -1649,9 +1651,12 @@ pub fn parse_glob_pattern(
|
||||
let bytes = trim_quotes(bytes);
|
||||
|
||||
if let Ok(token) = String::from_utf8(bytes.into()) {
|
||||
let filepath = nu_path::expand_path(token);
|
||||
let filepath = filepath.to_string_lossy().to_string();
|
||||
|
||||
(
|
||||
Expression {
|
||||
expr: Expr::GlobPattern(token),
|
||||
expr: Expr::GlobPattern(filepath),
|
||||
span,
|
||||
ty: Type::String,
|
||||
custom_completion: None,
|
||||
|
Loading…
Reference in New Issue
Block a user