From f5f9d56c379ef9e9371153c3210f2bb780aeeefe Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Thu, 17 Feb 2022 09:55:17 -0500 Subject: [PATCH] Move to a standard kebab/snake style (#4509) --- .../nu-command/src/core_commands/error_make.rs | 2 +- .../nu-command/src/dataframe/eager/aggregate.rs | 2 +- crates/nu-command/src/dataframe/eager/open.rs | 6 +++--- crates/nu-command/src/dataframe/eager/pivot.rs | 4 ++-- crates/nu-command/src/dataframe/eager/to_csv.rs | 2 +- crates/nu-command/src/formats/to/html.rs | 8 ++++---- crates/nu-command/src/hash/base64.rs | 4 ++-- crates/nu-command/src/platform/du.rs | 2 +- crates/nu-command/src/shells/exit.rs | 2 +- crates/nu-command/src/shells/g.rs | 2 +- crates/nu-command/src/strings/detect_columns.rs | 4 ++-- crates/nu-command/src/system/run_external.rs | 8 ++++---- crates/nu-command/src/viewers/table.rs | 4 ++-- crates/nu-command/tests/commands/hash_/mod.rs | 4 ++-- .../nu-command/tests/format_conversions/html.rs | 6 +++--- crates/nu-engine/src/eval.rs | 4 ++-- crates/nu-parser/src/known_external.rs | 4 ++-- .../src/serializers/capnp/plugin_call.rs | 4 ++-- .../nu-plugin/src/serializers/capnp/signature.rs | 4 ++-- crates/nu-plugin/src/serializers/json.rs | 4 ++-- crates/nu-protocol/tests/test_signature.rs | 16 ++++++++-------- crates/nu_plugin_query/src/nu/mod.rs | 4 ++-- crates/nu_plugin_query/src/query_web.rs | 4 ++-- crates/nu_plugin_s3/src/handler.rs | 4 ++-- crates/nu_plugin_s3/src/nu/mod.rs | 4 ++-- 25 files changed, 56 insertions(+), 56 deletions(-) diff --git a/crates/nu-command/src/core_commands/error_make.rs b/crates/nu-command/src/core_commands/error_make.rs index b596c0e493..a31ec5a397 100644 --- a/crates/nu-command/src/core_commands/error_make.rs +++ b/crates/nu-command/src/core_commands/error_make.rs @@ -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) } diff --git a/crates/nu-command/src/dataframe/eager/aggregate.rs b/crates/nu-command/src/dataframe/eager/aggregate.rs index 66017c41ac..efa7a0043b 100644 --- a/crates/nu-command/src/dataframe/eager/aggregate.rs +++ b/crates/nu-command/src/dataframe/eager/aggregate.rs @@ -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", diff --git a/crates/nu-command/src/dataframe/eager/open.rs b/crates/nu-command/src/dataframe/eager/open.rs index 0bc069a7fd..e213f84490 100644 --- a/crates/nu-command/src/dataframe/eager/open.rs +++ b/crates/nu-command/src/dataframe/eager/open.rs @@ -157,9 +157,9 @@ fn from_csv( ) -> Result { let file: Spanned = call.req(engine_state, stack, 0)?; let delimiter: Option> = call.get_flag(engine_state, stack, "delimiter")?; - let no_header: bool = call.has_flag("no_header"); - let infer_schema: Option = call.get_flag(engine_state, stack, "infer_schema")?; - let skip_rows: Option = call.get_flag(engine_state, stack, "skip_rows")?; + let no_header: bool = call.has_flag("no-header"); + let infer_schema: Option = call.get_flag(engine_state, stack, "infer-schema")?; + let skip_rows: Option = call.get_flag(engine_state, stack, "skip-rows")?; let columns: Option> = call.get_flag(engine_state, stack, "columns")?; let csv_reader = CsvReader::from_path(&file.item) diff --git a/crates/nu-command/src/dataframe/eager/pivot.rs b/crates/nu-command/src/dataframe/eager/pivot.rs index d2feb84618..1f5e56e5d0 100644 --- a/crates/nu-command/src/dataframe/eager/pivot.rs +++ b/crates/nu-command/src/dataframe/eager/pivot.rs @@ -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", ) diff --git a/crates/nu-command/src/dataframe/eager/to_csv.rs b/crates/nu-command/src/dataframe/eager/to_csv.rs index 5db04a11f9..df87e4216d 100644 --- a/crates/nu-command/src/dataframe/eager/to_csv.rs +++ b/crates/nu-command/src/dataframe/eager/to_csv.rs @@ -69,7 +69,7 @@ fn command( ) -> Result { let file_name: Spanned = call.req(engine_state, stack, 0)?; let delimiter: Option> = 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)?; diff --git a/crates/nu-command/src/formats/to/html.rs b/crates/nu-command/src/formats/to/html.rs index 60fc130e2d..bcaa652184 100644 --- a/crates/nu-command/src/formats/to/html.rs +++ b/crates/nu-command/src/formats/to/html.rs @@ -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 { 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"); diff --git a/crates/nu-command/src/hash/base64.rs b/crates/nu-command/src/hash/base64.rs index 0a5ccc424e..7cf563e1bb 100644 --- a/crates/nu-command/src/hash/base64.rs +++ b/crates/nu-command/src/hash/base64.rs @@ -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> = - call.get_flag(engine_state, stack, "character_set")?; + call.get_flag(engine_state, stack, "character-set")?; let column_paths: Vec = call.rest(engine_state, stack, 0)?; if encode && decode { diff --git a/crates/nu-command/src/platform/du.rs b/crates/nu-command/src/platform/du.rs index d47dd7e727..7acd997f3a 100644 --- a/crates/nu-command/src/platform/du.rs +++ b/crates/nu-command/src/platform/du.rs @@ -90,7 +90,7 @@ impl Command for Du { max_depth: call .get_flag::(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| { diff --git a/crates/nu-command/src/shells/exit.rs b/crates/nu-command/src/shells/exit.rs index e2a355922d..30ecf006da 100644 --- a/crates/nu-command/src/shells/exit.rs +++ b/crates/nu-command/src/shells/exit.rs @@ -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", ) diff --git a/crates/nu-command/src/shells/g.rs b/crates/nu-command/src/shells/g.rs index 64bc10169e..c9f5f27052 100644 --- a/crates/nu-command/src/shells/g.rs +++ b/crates/nu-command/src/shells/g.rs @@ -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", ) diff --git a/crates/nu-command/src/strings/detect_columns.rs b/crates/nu-command/src/strings/detect_columns.rs index bdd533e78b..4e3f2f7a81 100644 --- a/crates/nu-command/src/strings/detect_columns.rs +++ b/crates/nu-command/src/strings/detect_columns.rs @@ -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 { let name_span = call.head; let num_rows_to_skip: Option = 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)?; diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index c5c7b68149..26c398cbf1 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -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 { let name: Spanned = call.req(engine_state, stack, 0)?; let args: Vec = 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(); diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index 993ee7e145..513e49cb73 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -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 = call.get_flag(engine_state, stack, "start_number")?; + let start_num: Option = 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() { diff --git a/crates/nu-command/tests/commands/hash_/mod.rs b/crates/nu-command/tests/commands/hash_/mod.rs index 54eede3d38..0a325d4549 100644 --- a/crates/nu-command/tests/commands/hash_/mod.rs +++ b/crates/nu-command/tests/commands/hash_/mod.rs @@ -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 "# ) ); diff --git a/crates/nu-command/tests/format_conversions/html.rs b/crates/nu-command/tests/format_conversions/html.rs index f670ee087b..72d418ab86 100644 --- a/crates/nu-command/tests/format_conversions/html.rs +++ b/crates/nu-command/tests/format_conversions/html.rs @@ -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 "# ) ); diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 6890904c23..7cf6760159 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -172,7 +172,7 @@ fn eval_external( last_expression: bool, ) -> Result { 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, diff --git a/crates/nu-parser/src/known_external.rs b/crates/nu-parser/src/known_external.rs index 3e122c3f5a..6009cbc15e 100644 --- a/crates/nu-parser/src/known_external.rs +++ b/crates/nu-parser/src/known_external.rs @@ -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, diff --git a/crates/nu-plugin/src/serializers/capnp/plugin_call.rs b/crates/nu-plugin/src/serializers/capnp/plugin_call.rs index fcaa27af0d..3a4cd1e9a8 100644 --- a/crates/nu-plugin/src/serializers/capnp/plugin_call.rs +++ b/crates/nu-plugin/src/serializers/capnp/plugin_call.rs @@ -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'), diff --git a/crates/nu-plugin/src/serializers/capnp/signature.rs b/crates/nu-plugin/src/serializers/capnp/signature.rs index 51f19da743..82be9eac0e 100644 --- a/crates/nu-plugin/src/serializers/capnp/signature.rs +++ b/crates/nu-plugin/src/serializers/capnp/signature.rs @@ -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) diff --git a/crates/nu-plugin/src/serializers/json.rs b/crates/nu-plugin/src/serializers/json.rs index b21ccae1b4..7d16cab305 100644 --- a/crates/nu-plugin/src/serializers/json.rs +++ b/crates/nu-plugin/src/serializers/json.rs @@ -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'), diff --git a/crates/nu-protocol/tests/test_signature.rs b/crates/nu-protocol/tests/test_signature.rs index 3a9048824f..a2d1ce0f6e 100644 --- a/crates/nu-protocol/tests/test_signature.rs +++ b/crates/nu-protocol/tests/test_signature.rs @@ -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'), diff --git a/crates/nu_plugin_query/src/nu/mod.rs b/crates/nu_plugin_query/src/nu/mod.rs index 8322f877a5..9fa567e5b9 100644 --- a/crates/nu_plugin_query/src/nu/mod.rs +++ b/crates/nu_plugin_query/src/nu/mod.rs @@ -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'), diff --git a/crates/nu_plugin_query/src/query_web.rs b/crates/nu_plugin_query/src/query_web.rs index 422f7e8e7a..c2981b47f2 100644 --- a/crates/nu_plugin_query/src/query_web.rs +++ b/crates/nu_plugin_query/src/query_web.rs @@ -35,12 +35,12 @@ pub fn parse_selector_params(call: &EvaluatedCall, input: &Value) -> Result 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), }; diff --git a/crates/nu_plugin_s3/src/handler.rs b/crates/nu_plugin_s3/src/handler.rs index 4cdcf68816..ebb5c188b1 100644 --- a/crates/nu_plugin_s3/src/handler.rs +++ b/crates/nu_plugin_s3/src/handler.rs @@ -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( diff --git a/crates/nu_plugin_s3/src/nu/mod.rs b/crates/nu_plugin_s3/src/nu/mod.rs index d93aadf79a..2ad0b88d04 100644 --- a/crates/nu_plugin_s3/src/nu/mod.rs +++ b/crates/nu_plugin_s3/src/nu/mod.rs @@ -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'),