mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 07:18:19 +02:00
refactor: rename subcommand structs (#15309)
Came from [this discussion](https://discord.com/channels/601130461678272522/1348791953784836147/1349699872059691038) on discord with @fdncred # Description Small refactoring where I rename commands from "SubCommand" to its proper name. Motivations: better clarity (although subjective), better searchable, consistency. The only commands I didn't touch were "split list" and "ansi gradient" because of name clashes. # User-Facing Changes None # Tests + Formatting cargo fmt and clippy OK # After Submitting nothing required
This commit is contained in:
@ -4,9 +4,9 @@ use nu_engine::command_prelude::*;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct SplitChars;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for SplitChars {
|
||||
fn name(&self) -> &str {
|
||||
"split chars"
|
||||
}
|
||||
@ -173,6 +173,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(SplitChars {})
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ use fancy_regex::{escape, Regex};
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct SplitColumn;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for SplitColumn {
|
||||
fn name(&self) -> &str {
|
||||
"split column"
|
||||
}
|
||||
@ -275,6 +275,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(SplitColumn {})
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use nu_engine::{command_prelude::*, get_full_help};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SplitCommand;
|
||||
pub struct Split;
|
||||
|
||||
impl Command for SplitCommand {
|
||||
impl Command for Split {
|
||||
fn name(&self) -> &str {
|
||||
"split"
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ mod list;
|
||||
mod row;
|
||||
mod words;
|
||||
|
||||
pub use chars::SubCommand as SplitChars;
|
||||
pub use column::SubCommand as SplitColumn;
|
||||
pub use command::SplitCommand as Split;
|
||||
pub use chars::SplitChars;
|
||||
pub use column::SplitColumn;
|
||||
pub use command::Split;
|
||||
pub use list::SubCommand as SplitList;
|
||||
pub use row::SubCommand as SplitRow;
|
||||
pub use words::SubCommand as SplitWords;
|
||||
pub use row::SplitRow;
|
||||
pub use words::SplitWords;
|
||||
|
@ -2,9 +2,9 @@ use fancy_regex::{escape, Regex};
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct SplitRow;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for SplitRow {
|
||||
fn name(&self) -> &str {
|
||||
"split row"
|
||||
}
|
||||
@ -239,6 +239,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(SplitRow {})
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ use nu_engine::command_prelude::*;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct SplitWords;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for SplitWords {
|
||||
fn name(&self) -> &str {
|
||||
"split words"
|
||||
}
|
||||
@ -420,7 +420,7 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(SplitWords {})
|
||||
}
|
||||
#[test]
|
||||
fn mixed_letter_number() {
|
||||
|
@ -1,9 +1,9 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrCapitalize;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrCapitalize {
|
||||
fn name(&self) -> &str {
|
||||
"str capitalize"
|
||||
}
|
||||
@ -145,6 +145,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrCapitalize {})
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrDowncase;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrDowncase {
|
||||
fn name(&self) -> &str {
|
||||
"str downcase"
|
||||
}
|
||||
@ -143,6 +143,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrDowncase {})
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ mod downcase;
|
||||
mod str_;
|
||||
mod upcase;
|
||||
|
||||
pub use capitalize::SubCommand as StrCapitalize;
|
||||
pub use downcase::SubCommand as StrDowncase;
|
||||
pub use capitalize::StrCapitalize;
|
||||
pub use downcase::StrDowncase;
|
||||
pub use str_::Str;
|
||||
pub use upcase::SubCommand as StrUpcase;
|
||||
pub use upcase::StrUpcase;
|
||||
|
||||
use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument};
|
||||
use nu_engine::command_prelude::*;
|
||||
|
@ -1,9 +1,9 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrUpcase;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrUpcase {
|
||||
fn name(&self) -> &str {
|
||||
"str upcase"
|
||||
}
|
||||
@ -116,13 +116,13 @@ fn action(input: &Value, head: Span) -> Value {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use super::{action, SubCommand};
|
||||
use super::{action, StrUpcase};
|
||||
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrUpcase {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4,7 +4,7 @@ use nu_engine::command_prelude::*;
|
||||
use nu_utils::IgnoreCaseExt;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrContains;
|
||||
|
||||
struct Arguments {
|
||||
substring: String,
|
||||
@ -18,7 +18,7 @@ impl CmdArgument for Arguments {
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrContains {
|
||||
fn name(&self) -> &str {
|
||||
"str contains"
|
||||
}
|
||||
@ -187,6 +187,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrContains {})
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use nu_engine::command_prelude::*;
|
||||
use nu_protocol::{engine::StateWorkingSet, levenshtein_distance};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrDistance;
|
||||
|
||||
struct Arguments {
|
||||
compare_string: String,
|
||||
@ -16,7 +16,7 @@ impl CmdArgument for Arguments {
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrDistance {
|
||||
fn name(&self) -> &str {
|
||||
"str distance"
|
||||
}
|
||||
@ -148,6 +148,6 @@ mod tests {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrDistance {})
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ impl CmdArgument for Arguments {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrEndswith;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrEndswith {
|
||||
fn name(&self) -> &str {
|
||||
"str ends-with"
|
||||
}
|
||||
@ -149,6 +149,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrEndswith {})
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrExpand;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrExpand {
|
||||
fn name(&self) -> &str {
|
||||
"str expand"
|
||||
}
|
||||
@ -377,6 +377,6 @@ mod tests {
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrExpand {})
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ impl CmdArgument for Arguments {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrIndexOf;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrIndexOf {
|
||||
fn name(&self) -> &str {
|
||||
"str index-of"
|
||||
}
|
||||
@ -246,13 +246,13 @@ mod tests {
|
||||
use nu_protocol::ast::RangeInclusion;
|
||||
|
||||
use super::*;
|
||||
use super::{action, Arguments, SubCommand};
|
||||
use super::{action, Arguments, StrIndexOf};
|
||||
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrIndexOf {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -16,9 +16,9 @@ impl CmdArgument for Arguments {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrLength;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrLength {
|
||||
fn name(&self) -> &str {
|
||||
"str length"
|
||||
}
|
||||
@ -177,6 +177,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrLength {})
|
||||
}
|
||||
}
|
||||
|
@ -14,16 +14,16 @@ mod substring;
|
||||
mod trim;
|
||||
|
||||
pub use case::*;
|
||||
pub use contains::SubCommand as StrContains;
|
||||
pub use distance::SubCommand as StrDistance;
|
||||
pub use ends_with::SubCommand as StrEndswith;
|
||||
pub use expand::SubCommand as StrExpand;
|
||||
pub use index_of::SubCommand as StrIndexOf;
|
||||
pub use contains::StrContains;
|
||||
pub use distance::StrDistance;
|
||||
pub use ends_with::StrEndswith;
|
||||
pub use expand::StrExpand;
|
||||
pub use index_of::StrIndexOf;
|
||||
pub use join::*;
|
||||
pub use length::SubCommand as StrLength;
|
||||
pub use replace::SubCommand as StrReplace;
|
||||
pub use reverse::SubCommand as StrReverse;
|
||||
pub use starts_with::SubCommand as StrStartsWith;
|
||||
pub use stats::SubCommand as StrStats;
|
||||
pub use substring::SubCommand as StrSubstring;
|
||||
pub use trim::Trim as StrTrim;
|
||||
pub use length::StrLength;
|
||||
pub use replace::StrReplace;
|
||||
pub use reverse::StrReverse;
|
||||
pub use starts_with::StrStartsWith;
|
||||
pub use stats::StrStats;
|
||||
pub use substring::StrSubstring;
|
||||
pub use trim::StrTrim;
|
||||
|
@ -19,9 +19,9 @@ impl CmdArgument for Arguments {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrReplace;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrReplace {
|
||||
fn name(&self) -> &str {
|
||||
"str replace"
|
||||
}
|
||||
@ -304,7 +304,7 @@ fn action(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use super::{action, Arguments, SubCommand};
|
||||
use super::{action, Arguments, StrReplace};
|
||||
|
||||
fn test_spanned_string(val: &str) -> Spanned<String> {
|
||||
Spanned {
|
||||
@ -317,7 +317,7 @@ mod tests {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrReplace {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2,9 +2,9 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs};
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrReverse;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrReverse {
|
||||
fn name(&self) -> &str {
|
||||
"str reverse"
|
||||
}
|
||||
@ -117,6 +117,6 @@ mod tests {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrReverse {})
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ impl CmdArgument for Arguments {
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
pub struct SubCommand;
|
||||
pub struct StrStartsWith;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrStartsWith {
|
||||
fn name(&self) -> &str {
|
||||
"str starts-with"
|
||||
}
|
||||
@ -161,6 +161,6 @@ mod tests {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrStartsWith {})
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ use unicode_segmentation::UnicodeSegmentation;
|
||||
pub type Counted = BTreeMap<Counter, usize>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrStats;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrStats {
|
||||
fn name(&self) -> &str {
|
||||
"str stats"
|
||||
}
|
||||
@ -293,7 +293,7 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrStats {})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ use nu_protocol::{engine::StateWorkingSet, IntRange};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrSubstring;
|
||||
|
||||
struct Arguments {
|
||||
range: IntRange,
|
||||
@ -21,7 +21,7 @@ impl CmdArgument for Arguments {
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrSubstring {
|
||||
fn name(&self) -> &str {
|
||||
"str substring"
|
||||
}
|
||||
@ -188,13 +188,13 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value {
|
||||
mod tests {
|
||||
use nu_protocol::IntRange;
|
||||
|
||||
use super::{action, Arguments, Span, SubCommand, Value};
|
||||
use super::{action, Arguments, Span, StrSubstring, Value};
|
||||
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrSubstring {})
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
@ -1,2 +1,2 @@
|
||||
mod trim_;
|
||||
pub use trim_::SubCommand as Trim;
|
||||
pub use trim_::StrTrim;
|
||||
|
@ -2,7 +2,7 @@ use nu_cmd_base::input_handler::{operate, CmdArgument};
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct StrTrim;
|
||||
|
||||
struct Arguments {
|
||||
to_trim: Option<char>,
|
||||
@ -23,7 +23,7 @@ pub enum TrimSide {
|
||||
Both,
|
||||
}
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for StrTrim {
|
||||
fn name(&self) -> &str {
|
||||
"str trim"
|
||||
}
|
||||
@ -272,7 +272,7 @@ mod tests {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(StrTrim {})
|
||||
}
|
||||
|
||||
fn make_record(cols: Vec<&str>, vals: Vec<&str>) -> Value {
|
||||
|
Reference in New Issue
Block a user