Skip to content

Commit

Permalink
refactor: 🔨 Name enums in singular
Browse files Browse the repository at this point in the history
Why did I put them in plural in the first place...
  • Loading branch information
AntwortEinesLebens committed Nov 10, 2024
1 parent b7be769 commit 93bb02b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use clap::{Parser, Subcommand};
#[clap(arg_required_else_help = true)]
pub struct Arguments {
#[clap(subcommand)]
pub command: Commands,
pub command: Command,
}

#[derive(Subcommand)]
pub enum Commands {
pub enum Command {
Traces(Traces),
Generator(Generator),
}
8 changes: 4 additions & 4 deletions src/commands/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ pub mod processes;
pub struct Traces {
#[clap(subcommand)]
#[serde(flatten)]
pub command: Commands,
pub command: Command,
}

#[derive(Subcommand, Deserialize)]
#[serde(rename_all = "snake_case", untagged)]
pub enum Commands {
pub enum Command {
Drivers(Drivers),
Processes(Processes),
}
Expand All @@ -31,8 +31,8 @@ pub trait Runnable {
impl Runnable for Traces {
fn run(&self) -> Result<(), Box<dyn Error>> {
match &self.command {
Commands::Drivers(drivers) => drivers as &dyn Runnable,
Commands::Processes(processes) => processes,
Command::Drivers(drivers) => drivers as &dyn Runnable,
Command::Processes(processes) => processes,
}
.run()
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/traces/drivers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ pub mod byovd;
pub struct Drivers {
#[clap(subcommand)]
#[serde(flatten)]
pub command: Commands,
pub command: Command,
}

#[derive(Subcommand, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Commands {
pub enum Command {
Byovd(Byovd),
}

impl Runnable for Drivers {
fn run(&self) -> Result<(), Box<dyn Error>> {
match &self.command {
Commands::Byovd(byovd) => byovd as &dyn Runnable,
Command::Byovd(byovd) => byovd as &dyn Runnable,
}
.run()
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/traces/processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ pub mod spoofing;
pub struct Processes {
#[clap(subcommand)]
#[serde(flatten)]
pub command: Commands,
pub command: Command,
}

#[derive(Subcommand, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Commands {
pub enum Command {
Spoofing(Spoofing),
}

impl Runnable for Processes {
fn run(&self) -> Result<(), Box<dyn Error>> {
match &self.command {
Commands::Spoofing(spoofing) => spoofing as &dyn Runnable,
Command::Spoofing(spoofing) => spoofing as &dyn Runnable,
}
.run()
}
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ mod commands;
mod windows;

use clap::Parser;
use cli::{Arguments, Commands};
use cli::{Arguments, Command};
use commands::traces::Runnable;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
match Arguments::parse().command {
Commands::Traces(action) => action.run()?,
Commands::Generator(generator) => generator.generate()?,
Command::Traces(action) => action.run()?,
Command::Generator(generator) => generator.generate()?,
};

Ok(())
Expand Down

0 comments on commit 93bb02b

Please sign in to comment.