forked from extern/nushell
Changes flag to minimum-spaces
.
This commit is contained in:
parent
294c2c600d
commit
0d2044e72e
@ -7,7 +7,8 @@ pub struct FromSSV;
|
|||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct FromSSVArgs {
|
pub struct FromSSVArgs {
|
||||||
headerless: bool,
|
headerless: bool,
|
||||||
n: Option<Tagged<usize>>,
|
#[serde(rename(deserialize = "minimum-spaces"))]
|
||||||
|
minimum_spaces: Option<Tagged<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const STRING_REPRESENTATION: &str = "from-ssv";
|
const STRING_REPRESENTATION: &str = "from-ssv";
|
||||||
@ -21,7 +22,7 @@ impl WholeStreamCommand for FromSSV {
|
|||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build(STRING_REPRESENTATION)
|
Signature::build(STRING_REPRESENTATION)
|
||||||
.switch("headerless")
|
.switch("headerless")
|
||||||
.named("n", SyntaxShape::Int)
|
.named("minimum-spaces", SyntaxShape::Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
@ -103,14 +104,17 @@ fn from_ssv_string_to_value(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn from_ssv(
|
fn from_ssv(
|
||||||
FromSSVArgs { headerless, n }: FromSSVArgs,
|
FromSSVArgs {
|
||||||
|
headerless,
|
||||||
|
minimum_spaces,
|
||||||
|
}: FromSSVArgs,
|
||||||
RunnableContext { input, name, .. }: RunnableContext,
|
RunnableContext { input, name, .. }: RunnableContext,
|
||||||
) -> Result<OutputStream, ShellError> {
|
) -> Result<OutputStream, ShellError> {
|
||||||
let stream = async_stream! {
|
let stream = async_stream! {
|
||||||
let values: Vec<Tagged<Value>> = input.values.collect().await;
|
let values: Vec<Tagged<Value>> = input.values.collect().await;
|
||||||
let mut concat_string = String::new();
|
let mut concat_string = String::new();
|
||||||
let mut latest_tag: Option<Tag> = None;
|
let mut latest_tag: Option<Tag> = None;
|
||||||
let split_at = match n {
|
let split_at = match minimum_spaces {
|
||||||
Some(number) => number.item,
|
Some(number) => number.item,
|
||||||
None => DEFAULT_ALLOWED_SPACES
|
None => DEFAULT_ALLOWED_SPACES
|
||||||
};
|
};
|
||||||
|
@ -400,7 +400,7 @@ fn converts_from_ssv_text_to_structured_table_with_separator_specified() {
|
|||||||
cwd: dirs.test(), h::pipeline(
|
cwd: dirs.test(), h::pipeline(
|
||||||
r#"
|
r#"
|
||||||
open oc_get_svc.txt
|
open oc_get_svc.txt
|
||||||
| from-ssv -n 3
|
| from-ssv --minimum-spaces 3
|
||||||
| nth 0
|
| nth 0
|
||||||
| get IP
|
| get IP
|
||||||
| echo $it
|
| echo $it
|
||||||
|
Loading…
Reference in New Issue
Block a user