mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Move to a standard kebab/snake style (#4509)
This commit is contained in:
parent
d50ccdf083
commit
f5f9d56c37
25 changed files with 56 additions and 56 deletions
|
@ -16,7 +16,7 @@ impl Command for ErrorMake {
|
|||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("error make")
|
||||
.optional("error-struct", SyntaxShape::Record, "the error to create")
|
||||
.optional("error_struct", SyntaxShape::Record, "the error to create")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ impl Command for Aggregate {
|
|||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required(
|
||||
"operation-name",
|
||||
"operation_name",
|
||||
SyntaxShape::String,
|
||||
"\n\tDataframes: mean, sum, min, max, quantile, median, var, std
|
||||
\tGroupBy: mean, sum, min, max, first, last, nunique, quantile, median, var, std, count",
|
||||
|
|
|
@ -157,9 +157,9 @@ fn from_csv(
|
|||
) -> Result<polars::prelude::DataFrame, ShellError> {
|
||||
let file: Spanned<PathBuf> = call.req(engine_state, stack, 0)?;
|
||||
let delimiter: Option<Spanned<String>> = call.get_flag(engine_state, stack, "delimiter")?;
|
||||
let no_header: bool = call.has_flag("no_header");
|
||||
let infer_schema: Option<usize> = call.get_flag(engine_state, stack, "infer_schema")?;
|
||||
let skip_rows: Option<usize> = call.get_flag(engine_state, stack, "skip_rows")?;
|
||||
let no_header: bool = call.has_flag("no-header");
|
||||
let infer_schema: Option<usize> = call.get_flag(engine_state, stack, "infer-schema")?;
|
||||
let skip_rows: Option<usize> = call.get_flag(engine_state, stack, "skip-rows")?;
|
||||
let columns: Option<Vec<String>> = call.get_flag(engine_state, stack, "columns")?;
|
||||
|
||||
let csv_reader = CsvReader::from_path(&file.item)
|
||||
|
|
|
@ -53,12 +53,12 @@ impl Command for PivotDF {
|
|||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required(
|
||||
"pivot-column",
|
||||
"pivot_column",
|
||||
SyntaxShape::String,
|
||||
"pivot column to perform pivot",
|
||||
)
|
||||
.required(
|
||||
"value-column",
|
||||
"value_column",
|
||||
SyntaxShape::String,
|
||||
"value column to perform pivot",
|
||||
)
|
||||
|
|
|
@ -69,7 +69,7 @@ fn command(
|
|||
) -> Result<PipelineData, ShellError> {
|
||||
let file_name: Spanned<PathBuf> = call.req(engine_state, stack, 0)?;
|
||||
let delimiter: Option<Spanned<String>> = call.get_flag(engine_state, stack, "delimiter")?;
|
||||
let no_header: bool = call.has_flag("no_header");
|
||||
let no_header: bool = call.has_flag("no-header");
|
||||
|
||||
let df = NuDataFrame::try_from_pipeline(input, call.head)?;
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ impl Command for ToHtml {
|
|||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("to html")
|
||||
.switch("html_color", "change ansi colors to html colors", Some('c'))
|
||||
.switch("no_color", "remove all ansi colors in output", Some('n'))
|
||||
.switch("html-color", "change ansi colors to html colors", Some('c'))
|
||||
.switch("no-color", "remove all ansi colors in output", Some('n'))
|
||||
.switch(
|
||||
"dark",
|
||||
"indicate your background color is a darker color",
|
||||
|
@ -289,8 +289,8 @@ fn to_html(
|
|||
stack: &mut Stack,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let head = call.head;
|
||||
let html_color = call.has_flag("html_color");
|
||||
let no_color = call.has_flag("no_color");
|
||||
let html_color = call.has_flag("html-color");
|
||||
let no_color = call.has_flag("no-color");
|
||||
let dark = call.has_flag("dark");
|
||||
let partial = call.has_flag("partial");
|
||||
let list = call.has_flag("list");
|
||||
|
|
|
@ -29,7 +29,7 @@ impl Command for Base64 {
|
|||
fn signature(&self) -> Signature {
|
||||
Signature::build("hash base64")
|
||||
.named(
|
||||
"character_set",
|
||||
"character-set",
|
||||
SyntaxShape::String,
|
||||
"specify the character rules for encoding the input.\n\
|
||||
\tValid values are 'standard', 'standard-no-padding', 'url-safe', 'url-safe-no-padding',\
|
||||
|
@ -98,7 +98,7 @@ fn operate(
|
|||
let encode = call.has_flag("encode");
|
||||
let decode = call.has_flag("decode");
|
||||
let character_set: Option<Spanned<String>> =
|
||||
call.get_flag(engine_state, stack, "character_set")?;
|
||||
call.get_flag(engine_state, stack, "character-set")?;
|
||||
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
|
||||
|
||||
if encode && decode {
|
||||
|
|
|
@ -90,7 +90,7 @@ impl Command for Du {
|
|||
max_depth: call
|
||||
.get_flag::<i64>(engine_state, stack, "max-depth")?
|
||||
.map(|n| (n as u64).try_into().expect("error converting i64 to u64")),
|
||||
min_size: call.get_flag(engine_state, stack, "min_size")?,
|
||||
min_size: call.get_flag(engine_state, stack, "min-size")?,
|
||||
};
|
||||
|
||||
let exclude = args.exclude.map_or(Ok(None), move |x| {
|
||||
|
|
|
@ -15,7 +15,7 @@ impl Command for Exit {
|
|||
fn signature(&self) -> Signature {
|
||||
Signature::build("exit")
|
||||
.optional(
|
||||
"exit-code",
|
||||
"exit_code",
|
||||
SyntaxShape::Int,
|
||||
"Exit code to return immediately with",
|
||||
)
|
||||
|
|
|
@ -15,7 +15,7 @@ impl Command for GotoShell {
|
|||
fn signature(&self) -> Signature {
|
||||
Signature::build("g")
|
||||
.required(
|
||||
"shell-number",
|
||||
"shell_number",
|
||||
SyntaxShape::Int,
|
||||
"shell number to change to",
|
||||
)
|
||||
|
|
|
@ -27,7 +27,7 @@ impl Command for DetectColumns {
|
|||
"number of rows to skip before detecting",
|
||||
Some('s'),
|
||||
)
|
||||
.switch("no_headers", "don't detect headers", Some('n'))
|
||||
.switch("no-headers", "don't detect headers", Some('n'))
|
||||
.category(Category::Strings)
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ fn detect_columns(
|
|||
) -> Result<PipelineData, ShellError> {
|
||||
let name_span = call.head;
|
||||
let num_rows_to_skip: Option<usize> = call.get_flag(engine_state, stack, "skip")?;
|
||||
let noheader = call.has_flag("no_headers");
|
||||
let noheader = call.has_flag("no-headers");
|
||||
let ctrlc = engine_state.ctrlc.clone();
|
||||
let config = stack.get_config()?;
|
||||
let input = input.collect_string("", &config)?;
|
||||
|
|
|
@ -23,7 +23,7 @@ pub struct External;
|
|||
|
||||
impl Command for External {
|
||||
fn name(&self) -> &str {
|
||||
"run_external"
|
||||
"run-external"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -35,8 +35,8 @@ impl Command for External {
|
|||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("run_external")
|
||||
.switch("last_expression", "last_expression", None)
|
||||
Signature::build("run-external")
|
||||
.switch("last-expression", "last-expression", None)
|
||||
.rest("rest", SyntaxShape::Any, "external command to run")
|
||||
.category(Category::System)
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ impl Command for External {
|
|||
) -> Result<PipelineData, ShellError> {
|
||||
let name: Spanned<String> = call.req(engine_state, stack, 0)?;
|
||||
let args: Vec<Value> = call.rest(engine_state, stack, 1)?;
|
||||
let last_expression = call.has_flag("last_expression");
|
||||
let last_expression = call.has_flag("last-expression");
|
||||
|
||||
// Translate environment variables from Values to Strings
|
||||
let config = stack.get_config().unwrap_or_default();
|
||||
|
|
|
@ -33,7 +33,7 @@ impl Command for Table {
|
|||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("table")
|
||||
.named(
|
||||
"start_number",
|
||||
"start-number",
|
||||
SyntaxShape::Int,
|
||||
"row number to start viewing from",
|
||||
Some('n'),
|
||||
|
@ -52,7 +52,7 @@ impl Command for Table {
|
|||
let ctrlc = engine_state.ctrlc.clone();
|
||||
let config = stack.get_config().unwrap_or_default();
|
||||
let color_hm = get_color_config(&config);
|
||||
let start_num: Option<i64> = call.get_flag(engine_state, stack, "start_number")?;
|
||||
let start_num: Option<i64> = call.get_flag(engine_state, stack, "start-number")?;
|
||||
let row_offset = start_num.unwrap_or_default() as usize;
|
||||
|
||||
let term_width = if let Some((Width(w), Height(_h))) = terminal_size::terminal_size() {
|
||||
|
|
|
@ -18,7 +18,7 @@ fn base64_encode_characterset_binhex() {
|
|||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 'username:password' | hash base64 --character_set binhex --encode
|
||||
echo 'username:password' | hash base64 --character-set binhex --encode
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
@ -63,7 +63,7 @@ fn error_invalid_decode_value() {
|
|||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo "this should not be a valid encoded value" | hash base64 --character_set url-safe --decode
|
||||
echo "this should not be a valid encoded value" | hash base64 --character-set url-safe --decode
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
|
|
@ -50,7 +50,7 @@ fn test_cd_html_color_flag_dark_false() {
|
|||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
cd --help | to html --html_color
|
||||
cd --help | to html --html-color
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
@ -65,7 +65,7 @@ fn test_no_color_flag() {
|
|||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
cd --help | to html --no_color
|
||||
cd --help | to html --no-color
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
@ -80,7 +80,7 @@ fn test_html_color_where_flag_dark_false() {
|
|||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
where --help | to html --html_color
|
||||
where --help | to html --html-color
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
|
|
@ -172,7 +172,7 @@ fn eval_external(
|
|||
last_expression: bool,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let decl_id = engine_state
|
||||
.find_decl("run_external".as_bytes())
|
||||
.find_decl("run-external".as_bytes())
|
||||
.ok_or(ShellError::ExternalNotSupported(head.span))?;
|
||||
|
||||
let command = engine_state.get_decl(decl_id);
|
||||
|
@ -188,7 +188,7 @@ fn eval_external(
|
|||
if last_expression {
|
||||
call.named.push((
|
||||
Spanned {
|
||||
item: "last_expression".into(),
|
||||
item: "last-expression".into(),
|
||||
span: head.span,
|
||||
},
|
||||
None,
|
||||
|
|
|
@ -48,7 +48,7 @@ impl Command for KnownExternal {
|
|||
match external_call.expr {
|
||||
Expr::ExternalCall(head, args) => {
|
||||
let decl_id = engine_state
|
||||
.find_decl("run_external".as_bytes())
|
||||
.find_decl("run-external".as_bytes())
|
||||
.ok_or(ShellError::ExternalNotSupported(head.span))?;
|
||||
|
||||
let command = engine_state.get_decl(decl_id);
|
||||
|
@ -64,7 +64,7 @@ impl Command for KnownExternal {
|
|||
// if last_expression {
|
||||
// call.named.push((
|
||||
// Spanned {
|
||||
// item: "last_expression".into(),
|
||||
// item: "last-expression".into(),
|
||||
// span: head.span,
|
||||
// },
|
||||
// None,
|
||||
|
|
|
@ -297,9 +297,9 @@ mod tests {
|
|||
let signature = Signature::build("nu-plugin")
|
||||
.required("first", SyntaxShape::String, "first required")
|
||||
.required("second", SyntaxShape::Int, "second required")
|
||||
.required_named("first_named", SyntaxShape::String, "first named", Some('f'))
|
||||
.required_named("first-named", SyntaxShape::String, "first named", Some('f'))
|
||||
.required_named(
|
||||
"second_named",
|
||||
"second-named",
|
||||
SyntaxShape::String,
|
||||
"second named",
|
||||
Some('s'),
|
||||
|
|
|
@ -301,8 +301,8 @@ mod tests {
|
|||
let signature = Signature::build("nu-plugin")
|
||||
.required("first", SyntaxShape::String, "first required")
|
||||
.required("second", SyntaxShape::Int, "second required")
|
||||
.required_named("first_named", SyntaxShape::String, "first named", Some('f'))
|
||||
.required_named("second_named", SyntaxShape::Int, "first named", Some('s'))
|
||||
.required_named("first-named", SyntaxShape::String, "first named", Some('f'))
|
||||
.required_named("second-named", SyntaxShape::Int, "first named", Some('s'))
|
||||
.required_named("name", SyntaxShape::String, "first named", Some('n'))
|
||||
.required_named("string", SyntaxShape::String, "second named", Some('x'))
|
||||
.switch("switch", "some switch", None)
|
||||
|
|
|
@ -149,9 +149,9 @@ mod tests {
|
|||
let signature = Signature::build("nu-plugin")
|
||||
.required("first", SyntaxShape::String, "first required")
|
||||
.required("second", SyntaxShape::Int, "second required")
|
||||
.required_named("first_named", SyntaxShape::String, "first named", Some('f'))
|
||||
.required_named("first-named", SyntaxShape::String, "first named", Some('f'))
|
||||
.required_named(
|
||||
"second_named",
|
||||
"second-named",
|
||||
SyntaxShape::String,
|
||||
"second named",
|
||||
Some('s'),
|
||||
|
|
|
@ -20,7 +20,7 @@ fn test_signature_chained() {
|
|||
.required("required", SyntaxShape::String, "required description")
|
||||
.optional("optional", SyntaxShape::String, "optional description")
|
||||
.required_named(
|
||||
"req_named",
|
||||
"req-named",
|
||||
SyntaxShape::String,
|
||||
"required named description",
|
||||
Some('r'),
|
||||
|
@ -36,7 +36,7 @@ fn test_signature_chained() {
|
|||
assert_eq!(signature.get_shorts(), vec!['h', 'r', 'n']);
|
||||
assert_eq!(
|
||||
signature.get_names(),
|
||||
vec!["help", "req_named", "named", "switch"]
|
||||
vec!["help", "req-named", "named", "switch"]
|
||||
);
|
||||
assert_eq!(signature.num_positionals(), 2);
|
||||
|
||||
|
@ -69,9 +69,9 @@ fn test_signature_chained() {
|
|||
);
|
||||
|
||||
assert_eq!(
|
||||
signature.get_long_flag("req_named"),
|
||||
signature.get_long_flag("req-named"),
|
||||
Some(Flag {
|
||||
long: "req_named".to_string(),
|
||||
long: "req-named".to_string(),
|
||||
short: Some('r'),
|
||||
arg: Some(SyntaxShape::String),
|
||||
required: true,
|
||||
|
@ -83,7 +83,7 @@ fn test_signature_chained() {
|
|||
assert_eq!(
|
||||
signature.get_short_flag('r'),
|
||||
Some(Flag {
|
||||
long: "req_named".to_string(),
|
||||
long: "req-named".to_string(),
|
||||
short: Some('r'),
|
||||
arg: Some(SyntaxShape::String),
|
||||
required: true,
|
||||
|
@ -99,7 +99,7 @@ fn test_signature_same_short() {
|
|||
// Creating signature with same short name should panic
|
||||
Signature::new("new_signature")
|
||||
.required_named(
|
||||
"required_named",
|
||||
"required-named",
|
||||
SyntaxShape::String,
|
||||
"required named description",
|
||||
Some('n'),
|
||||
|
@ -111,7 +111,7 @@ fn test_signature_same_short() {
|
|||
#[should_panic(expected = "There may be duplicate name flags, such as --help")]
|
||||
fn test_signature_same_name() {
|
||||
// Creating signature with same short name should panic
|
||||
Signature::new("new_signature")
|
||||
Signature::new("new-signature")
|
||||
.required_named(
|
||||
"name",
|
||||
SyntaxShape::String,
|
||||
|
@ -129,7 +129,7 @@ fn test_signature_round_trip() {
|
|||
.required("second", SyntaxShape::Int, "second required")
|
||||
.optional("optional", SyntaxShape::String, "optional description")
|
||||
.required_named(
|
||||
"req_named",
|
||||
"req-named",
|
||||
SyntaxShape::String,
|
||||
"required named description",
|
||||
Some('r'),
|
||||
|
|
|
@ -22,7 +22,7 @@ impl Plugin for Query {
|
|||
Signature::build("query web")
|
||||
.desc("execute selector query on html/web")
|
||||
.named("query", SyntaxShape::String, "selector query", Some('q'))
|
||||
.switch("as_html", "return the query output as html", Some('m'))
|
||||
.switch("as-html", "return the query output as html", Some('m'))
|
||||
.named(
|
||||
"attribute",
|
||||
SyntaxShape::String,
|
||||
|
@ -30,7 +30,7 @@ impl Plugin for Query {
|
|||
Some('a'),
|
||||
)
|
||||
.named(
|
||||
"as_table",
|
||||
"as-table",
|
||||
SyntaxShape::Table,
|
||||
"find table based on column header list",
|
||||
Some('t'),
|
||||
|
|
|
@ -35,12 +35,12 @@ pub fn parse_selector_params(call: &EvaluatedCall, input: &Value) -> Result<Valu
|
|||
Some(q2) => q2,
|
||||
None => "".to_string(),
|
||||
};
|
||||
let as_html = call.has_flag("as_html");
|
||||
let as_html = call.has_flag("as-html");
|
||||
let attribute: String = match call.get_flag("attribute")? {
|
||||
Some(a) => a,
|
||||
None => "".to_string(),
|
||||
};
|
||||
let as_table: Value = match call.get_flag("as_table")? {
|
||||
let as_table: Value = match call.get_flag("as-table")? {
|
||||
Some(v) => v,
|
||||
None => Value::nothing(head),
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ impl Handler {
|
|||
));
|
||||
}
|
||||
|
||||
if let Some(access_key) = call_info.args.get("access_key") {
|
||||
if let Some(access_key) = call_info.args.get("access-key") {
|
||||
self.config.access_key = access_key.as_string()?
|
||||
} else {
|
||||
return Err(ShellError::labeled_error(
|
||||
|
@ -62,7 +62,7 @@ impl Handler {
|
|||
));
|
||||
}
|
||||
|
||||
if let Some(secret_key) = call_info.args.get("secret_key") {
|
||||
if let Some(secret_key) = call_info.args.get("secret-key") {
|
||||
self.config.secret_key = secret_key.as_string()?
|
||||
} else {
|
||||
return Err(ShellError::labeled_error(
|
||||
|
|
|
@ -22,13 +22,13 @@ impl Plugin for handler::Handler {
|
|||
Some('e'),
|
||||
)
|
||||
.named(
|
||||
"access_key",
|
||||
"access-key",
|
||||
SyntaxShape::Any,
|
||||
"the access key when authenticating",
|
||||
Some('a'),
|
||||
)
|
||||
.named(
|
||||
"secret_key",
|
||||
"secret-key",
|
||||
SyntaxShape::Any,
|
||||
"the secret key when authenticating",
|
||||
Some('s'),
|
||||
|
|
Loading…
Reference in a new issue