-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from frack113/refactor/cli-organization
Refactor/cli organization
- Loading branch information
Showing
16 changed files
with
283 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-FileCopyrightText: 2023 The WAG development team | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use crate::actions::{ | ||
ads::ADS, drivers::Drivers, files::Files, mutexes::Mutexes, pipes::Pipes, processes::Processes, | ||
}; | ||
use clap::{Args, Subcommand}; | ||
|
||
pub mod ads; | ||
pub mod drivers; | ||
pub mod files; | ||
pub mod mutexes; | ||
pub mod pipes; | ||
pub mod processes; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Actions { | ||
#[clap(subcommand)] | ||
pub command: Commands, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum Commands { | ||
ADS(ADS), | ||
Drivers(Drivers), | ||
Files(Files), | ||
Mutexes(Mutexes), | ||
Pipes(Pipes), | ||
Processes(Processes), | ||
} | ||
|
||
pub trait Runnable { | ||
fn run(&self) -> i32; | ||
} | ||
|
||
impl Runnable for Actions { | ||
fn run(&self) -> i32 { | ||
return match &self.command { | ||
Commands::ADS(ads) => ads as &dyn Runnable, | ||
Commands::Drivers(drivers) => drivers, | ||
Commands::Files(files) => files, | ||
Commands::Mutexes(mutexes) => mutexes, | ||
Commands::Pipes(pipes) => pipes, | ||
Commands::Processes(processes) => processes, | ||
} | ||
.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-FileCopyrightText: 2023 The WAG development team | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use crate::actions::{ads::create::Create, Runnable}; | ||
use clap::{Args, Subcommand}; | ||
|
||
pub mod create; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct ADS { | ||
#[clap(subcommand)] | ||
pub command: Commands, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum Commands { | ||
Create(Create), | ||
} | ||
|
||
impl Runnable for ADS { | ||
fn run(&self) -> i32 { | ||
return match &self.command { | ||
Commands::Create(create) => create as &dyn Runnable, | ||
} | ||
.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-FileCopyrightText: 2023 The WAG development team | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use crate::actions::{drivers::create::Create, Runnable}; | ||
use clap::{Args, Subcommand}; | ||
|
||
pub mod create; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Drivers { | ||
#[clap(subcommand)] | ||
pub command: Commands, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum Commands { | ||
Create(Create), | ||
} | ||
|
||
impl Runnable for Drivers { | ||
fn run(&self) -> i32 { | ||
return match &self.command { | ||
Commands::Create(create) => create as &dyn Runnable, | ||
} | ||
.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-FileCopyrightText: 2023 The WAG development team | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use crate::actions::{files::create::Create, Runnable}; | ||
use clap::{Args, Subcommand}; | ||
|
||
pub mod create; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Files { | ||
#[clap(subcommand)] | ||
pub command: Commands, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum Commands { | ||
Create(Create), | ||
} | ||
|
||
impl Runnable for Files { | ||
fn run(&self) -> i32 { | ||
return match &self.command { | ||
Commands::Create(create) => create as &dyn Runnable, | ||
} | ||
.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-FileCopyrightText: 2023 The WAG development team | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use crate::actions::{mutexes::create::Create, Runnable}; | ||
use clap::{Args, Subcommand}; | ||
|
||
pub mod create; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Mutexes { | ||
#[clap(subcommand)] | ||
pub command: Commands, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum Commands { | ||
Create(Create), | ||
} | ||
|
||
impl Runnable for Mutexes { | ||
fn run(&self) -> i32 { | ||
return match &self.command { | ||
Commands::Create(create) => create as &dyn Runnable, | ||
} | ||
.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-FileCopyrightText: 2023 The WAG development team | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use crate::actions::{pipes::create::Create, Runnable}; | ||
use clap::{Args, Subcommand}; | ||
|
||
pub mod create; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Pipes { | ||
#[clap(subcommand)] | ||
pub command: Commands, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum Commands { | ||
Create(Create), | ||
} | ||
|
||
impl Runnable for Pipes { | ||
fn run(&self) -> i32 { | ||
return match &self.command { | ||
Commands::Create(create) => create as &dyn Runnable, | ||
} | ||
.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.