forked from extern/nushell
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"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"miette",
|
"miette",
|
||||||
|
"nu-path",
|
||||||
"nu-plugin",
|
"nu-plugin",
|
||||||
"nu-protocol",
|
"nu-protocol",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -8,6 +8,7 @@ miette = "3.0.0"
|
|||||||
thiserror = "1.0.29"
|
thiserror = "1.0.29"
|
||||||
nu-protocol = { path = "../nu-protocol"}
|
nu-protocol = { path = "../nu-protocol"}
|
||||||
nu-plugin = { path = "../nu-plugin", optional=true}
|
nu-plugin = { path = "../nu-plugin", optional=true}
|
||||||
|
nu-path = {path = "../nu-path"}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
plugin = ["nu-plugin"]
|
plugin = ["nu-plugin"]
|
||||||
|
@ -1437,9 +1437,11 @@ pub fn parse_filepath(
|
|||||||
let bytes = trim_quotes(bytes);
|
let bytes = trim_quotes(bytes);
|
||||||
|
|
||||||
if let Ok(token) = String::from_utf8(bytes.into()) {
|
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 {
|
Expression {
|
||||||
expr: Expr::Filepath(token),
|
expr: Expr::Filepath(filepath),
|
||||||
span,
|
span,
|
||||||
ty: Type::String,
|
ty: Type::String,
|
||||||
custom_completion: None,
|
custom_completion: None,
|
||||||
@ -1449,7 +1451,7 @@ pub fn parse_filepath(
|
|||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
garbage(span),
|
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);
|
let bytes = trim_quotes(bytes);
|
||||||
|
|
||||||
if let Ok(token) = String::from_utf8(bytes.into()) {
|
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 {
|
Expression {
|
||||||
expr: Expr::GlobPattern(token),
|
expr: Expr::GlobPattern(filepath),
|
||||||
span,
|
span,
|
||||||
ty: Type::String,
|
ty: Type::String,
|
||||||
custom_completion: None,
|
custom_completion: None,
|
||||||
|
Loading…
Reference in New Issue
Block a user