mirror of
https://github.com/nushell/nushell.git
synced 2025-05-09 12:34:26 +02:00
refactor(get)!: case sensitive by default
- remove `--sensitive(-s)` - add `--ignore-case(-I)`
This commit is contained in:
parent
e0812f6bc8
commit
05ff3c8e8e
@ -46,9 +46,9 @@ If multiple cell paths are given, this will produce a list of values."#
|
||||
Some('i'),
|
||||
)
|
||||
.switch(
|
||||
"sensitive",
|
||||
"get path in a case sensitive manner",
|
||||
Some('s'),
|
||||
"ignore-case",
|
||||
"get path in a case insensitive manner (make all cell path members case insensitive)",
|
||||
Some('I'),
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
@ -87,12 +87,12 @@ If multiple cell paths are given, this will produce a list of values."#
|
||||
},
|
||||
Example {
|
||||
description: "Getting Path/PATH in a case insensitive way",
|
||||
example: "$env | get paTH",
|
||||
example: "$env | get --ignore-case paTH",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Getting Path in a case sensitive way, won't work for 'PATH'",
|
||||
example: "$env | get --sensitive Path",
|
||||
example: "$env | get Path",
|
||||
result: None,
|
||||
},
|
||||
]
|
||||
@ -111,14 +111,14 @@ If multiple cell paths are given, this will produce a list of values."#
|
||||
let cell_path: CellPath = call.req_const(working_set, 0)?;
|
||||
let rest: Vec<CellPath> = call.rest_const(working_set, 1)?;
|
||||
let ignore_errors = call.has_flag_const(working_set, "ignore-errors")?;
|
||||
let sensitive = call.has_flag_const(working_set, "sensitive")?;
|
||||
let ignore_case = call.has_flag_const(working_set, "ignore-case")?;
|
||||
let metadata = input.metadata();
|
||||
action(
|
||||
input,
|
||||
cell_path,
|
||||
rest,
|
||||
ignore_errors,
|
||||
sensitive,
|
||||
ignore_case,
|
||||
working_set.permanent().signals().clone(),
|
||||
call.head,
|
||||
)
|
||||
@ -135,14 +135,14 @@ If multiple cell paths are given, this will produce a list of values."#
|
||||
let cell_path: CellPath = call.req(engine_state, stack, 0)?;
|
||||
let rest: Vec<CellPath> = call.rest(engine_state, stack, 1)?;
|
||||
let ignore_errors = call.has_flag(engine_state, stack, "ignore-errors")?;
|
||||
let sensitive = call.has_flag(engine_state, stack, "sensitive")?;
|
||||
let ignore_case = call.has_flag(engine_state, stack, "ignore-case")?;
|
||||
let metadata = input.metadata();
|
||||
action(
|
||||
input,
|
||||
cell_path,
|
||||
rest,
|
||||
ignore_errors,
|
||||
sensitive,
|
||||
ignore_case,
|
||||
engine_state.signals().clone(),
|
||||
call.head,
|
||||
)
|
||||
@ -155,7 +155,7 @@ fn action(
|
||||
mut cell_path: CellPath,
|
||||
mut rest: Vec<CellPath>,
|
||||
ignore_errors: bool,
|
||||
sensitive: bool,
|
||||
ignore_case: bool,
|
||||
signals: Signals,
|
||||
span: Span,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
@ -166,6 +166,13 @@ fn action(
|
||||
}
|
||||
}
|
||||
|
||||
if ignore_case {
|
||||
cell_path.make_insensitive();
|
||||
for path in &mut rest {
|
||||
path.make_insensitive();
|
||||
}
|
||||
}
|
||||
|
||||
match input {
|
||||
PipelineData::Empty => return Err(ShellError::PipelineEmpty { dst_span: span }),
|
||||
// Allow chaining of get -i
|
||||
|
Loading…
Reference in New Issue
Block a user