mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:06:03 +02:00
Nu glob (#4818)
* Fork glob. Normalise license holder * Fix more licenses * unwraps * bad doc test
This commit is contained in:
@ -13,6 +13,7 @@ nu-ansi-term = "0.42.0"
|
||||
|
||||
nu-color-config = { path = "../nu-color-config", version = "0.59.1" }
|
||||
nu-engine = { path = "../nu-engine", version = "0.59.1" }
|
||||
nu-glob = { path = "../nu-glob", version = "0.59.1" }
|
||||
nu-json = { path = "../nu-json", version = "0.59.1" }
|
||||
nu-parser = { path = "../nu-parser", version = "0.59.1" }
|
||||
nu-path = { path = "../nu-path", version = "0.59.1" }
|
||||
@ -39,7 +40,6 @@ eml-parser = "0.1.0"
|
||||
encoding_rs = "0.8.30"
|
||||
filesize = "0.2.0"
|
||||
fs_extra = "1.2.0"
|
||||
glob = "0.3.0"
|
||||
htmlescape = "0.3.1"
|
||||
ical = "0.7.0"
|
||||
indexmap = { version="1.7", features=["serde-1"] }
|
||||
|
@ -9,7 +9,7 @@ use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Spanne
|
||||
|
||||
use crate::filesystem::util::FileStructure;
|
||||
|
||||
const GLOB_PARAMS: glob::MatchOptions = glob::MatchOptions {
|
||||
const GLOB_PARAMS: nu_glob::MatchOptions = nu_glob::MatchOptions {
|
||||
case_sensitive: true,
|
||||
require_literal_separator: false,
|
||||
require_literal_leading_dot: false,
|
||||
@ -58,7 +58,7 @@ impl Command for Cp {
|
||||
let source = path.join(src.item.as_str());
|
||||
let destination = path.join(dst.item.as_str());
|
||||
|
||||
let sources: Vec<_> = match glob::glob_with(&source.to_string_lossy(), GLOB_PARAMS) {
|
||||
let sources: Vec<_> = match nu_glob::glob_with(&source.to_string_lossy(), GLOB_PARAMS) {
|
||||
Ok(files) => files.collect(),
|
||||
Err(e) => {
|
||||
return Err(ShellError::SpannedLabeledError(
|
||||
@ -193,7 +193,7 @@ impl Command for Cp {
|
||||
}
|
||||
|
||||
// let mut sources =
|
||||
// glob::glob(&source.to_string_lossy()).map_or_else(|_| Vec::new(), Iterator::collect);
|
||||
// nu_glob::glob(&source.to_string_lossy()).map_or_else(|_| Vec::new(), Iterator::collect);
|
||||
// if sources.is_empty() {
|
||||
// return Err(ShellError::FileNotFound(call.positional[0].span));
|
||||
// }
|
||||
|
@ -9,7 +9,7 @@ use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
|
||||
};
|
||||
|
||||
const GLOB_PARAMS: glob::MatchOptions = glob::MatchOptions {
|
||||
const GLOB_PARAMS: nu_glob::MatchOptions = nu_glob::MatchOptions {
|
||||
case_sensitive: true,
|
||||
require_literal_separator: false,
|
||||
require_literal_leading_dot: false,
|
||||
@ -62,7 +62,7 @@ impl Command for Mv {
|
||||
let source = path.join(spanned_source.item.as_str());
|
||||
let destination = path.join(spanned_destination.item.as_str());
|
||||
|
||||
let mut sources = glob::glob_with(&source.to_string_lossy(), GLOB_PARAMS)
|
||||
let mut sources = nu_glob::glob_with(&source.to_string_lossy(), GLOB_PARAMS)
|
||||
.map_or_else(|_| Vec::new(), Iterator::collect);
|
||||
|
||||
if sources.is_empty() {
|
||||
|
@ -16,7 +16,7 @@ use nu_protocol::{
|
||||
Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
const GLOB_PARAMS: glob::MatchOptions = glob::MatchOptions {
|
||||
const GLOB_PARAMS: nu_glob::MatchOptions = nu_glob::MatchOptions {
|
||||
case_sensitive: true,
|
||||
require_literal_separator: false,
|
||||
require_literal_leading_dot: false,
|
||||
@ -165,9 +165,9 @@ fn rm(
|
||||
}
|
||||
|
||||
let path = path.join(&target.item);
|
||||
match glob::glob_with(
|
||||
match nu_glob::glob_with(
|
||||
&path.to_string_lossy(),
|
||||
glob::MatchOptions {
|
||||
nu_glob::MatchOptions {
|
||||
require_literal_leading_dot: true,
|
||||
..GLOB_PARAMS
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
use filesize::file_real_size_fast;
|
||||
use glob::Pattern;
|
||||
use nu_glob::Pattern;
|
||||
use nu_protocol::{ShellError, Span, Value};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{DirBuilder, DirInfo, FileInfo};
|
||||
use glob::{GlobError, MatchOptions, Pattern};
|
||||
use nu_engine::CallExt;
|
||||
use nu_glob::{GlobError, MatchOptions, Pattern};
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
@ -103,9 +103,9 @@ impl Command for Du {
|
||||
let mut paths = match args.path {
|
||||
Some(p) => {
|
||||
let p = p.item.to_str().expect("Why isn't this encoded properly?");
|
||||
glob::glob_with(p, GLOB_PARAMS)
|
||||
nu_glob::glob_with(p, GLOB_PARAMS)
|
||||
}
|
||||
None => glob::glob_with("*", GLOB_PARAMS),
|
||||
None => nu_glob::glob_with("*", GLOB_PARAMS),
|
||||
}
|
||||
.map_err(|e| {
|
||||
ShellError::SpannedLabeledError(e.msg.to_string(), "glob error".to_string(), tag)
|
||||
|
@ -75,7 +75,7 @@ fn sort_primitive_values() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "authors = [\"The Nu Project Contributors\"]");
|
||||
assert_eq!(actual.out, "authors = [\"The Nushell Project Developers\"]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user