mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 02:57:53 +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:
@ -5,7 +5,7 @@ use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AnsiCommand;
|
||||
pub struct Ansi;
|
||||
|
||||
struct AnsiCode {
|
||||
short_name: Option<&'static str>,
|
||||
@ -505,7 +505,7 @@ static CODE_LIST: LazyLock<Vec<AnsiCode>> = LazyLock::new(|| { vec![
|
||||
static CODE_MAP: LazyLock<HashMap<&'static str, &'static str>> =
|
||||
LazyLock::new(|| build_ansi_hashmap(&CODE_LIST));
|
||||
|
||||
impl Command for AnsiCommand {
|
||||
impl Command for Ansi {
|
||||
fn name(&self) -> &str {
|
||||
"ansi"
|
||||
}
|
||||
@ -902,12 +902,12 @@ fn build_ansi_hashmap(v: &[AnsiCode]) -> HashMap<&str, &str> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::platform::ansi::ansi_::AnsiCommand;
|
||||
use crate::platform::ansi::ansi_::Ansi;
|
||||
|
||||
#[test]
|
||||
fn examples_work_as_expected() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(AnsiCommand {})
|
||||
test_examples(Ansi {})
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct AnsiLink;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for AnsiLink {
|
||||
fn name(&self) -> &str {
|
||||
"ansi link"
|
||||
}
|
||||
@ -144,12 +144,12 @@ fn add_osc_link(text: &str, link: &str) -> String {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::SubCommand;
|
||||
use super::AnsiLink;
|
||||
|
||||
#[test]
|
||||
fn examples_work_as_expected() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(AnsiLink {})
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ mod ansi_;
|
||||
mod link;
|
||||
mod strip;
|
||||
|
||||
pub use ansi_::AnsiCommand as Ansi;
|
||||
pub use link::SubCommand as AnsiLink;
|
||||
pub use strip::SubCommand as AnsiStrip;
|
||||
pub use ansi_::Ansi;
|
||||
pub use link::AnsiLink;
|
||||
pub use strip::AnsiStrip;
|
||||
|
@ -16,9 +16,9 @@ impl CmdArgument for Arguments {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
pub struct AnsiStrip;
|
||||
|
||||
impl Command for SubCommand {
|
||||
impl Command for AnsiStrip {
|
||||
fn name(&self) -> &str {
|
||||
"ansi strip"
|
||||
}
|
||||
@ -83,14 +83,14 @@ fn action(input: &Value, args: &Arguments, _span: Span) -> Value {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{action, Arguments, SubCommand};
|
||||
use super::{action, AnsiStrip, Arguments};
|
||||
use nu_protocol::{engine::EngineState, Span, Value};
|
||||
|
||||
#[test]
|
||||
fn examples_work_as_expected() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(SubCommand {})
|
||||
test_examples(AnsiStrip {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user