feat: update: #4518, Add example for register,source,save,shuffle and from tsv (#4577)

This commit is contained in:
Justin Ma
2022-02-21 20:25:41 +08:00
committed by GitHub
parent d454fad4dc
commit 968427c4e9
5 changed files with 84 additions and 6 deletions

View File

@ -2,7 +2,7 @@ use super::delimited::from_delimited_data;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Config, PipelineData, ShellError, Signature};
use nu_protocol::{Category, Config, Example, PipelineData, ShellError, Signature};
#[derive(Clone)]
pub struct FromTsv;
@ -36,6 +36,21 @@ impl Command for FromTsv {
let config = stack.get_config().unwrap_or_default();
from_tsv(call, input, &config)
}
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Create a tsv file with header columns and open it",
example: r#"echo $'c1(char tab)c2(char tab)c3(char nl)1(char tab)2(char tab)3' | save tsv-data | open tsv-data | from tsv"#,
result: None,
},
Example {
description: "Create a tsv file without header columns and open it",
example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv -n"#,
result: None,
},
]
}
}
fn from_tsv(call: &Call, input: PipelineData, config: &Config) -> Result<PipelineData, ShellError> {