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