This commit is contained in:
SkyfallWasTaken 2024-07-09 20:43:00 +01:00
parent acfcb28d28
commit f9d384d350
4 changed files with 31 additions and 3 deletions

3
.gitignore vendored
View file

@ -1 +1,4 @@
/target /target
package.json
package-lock.json
bun.lockb

View file

@ -1,10 +1,12 @@
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
pub mod run;
#[derive(Parser)] #[derive(Parser)]
#[command(version, about, long_about = None)] #[command(version, about, long_about = None)]
pub struct Cli { pub struct Cli {
#[command(subcommand)] #[command(subcommand)]
command: Commands, pub command: Commands,
} }
#[derive(Subcommand)] #[derive(Subcommand)]
@ -12,6 +14,20 @@ pub enum Commands {
/// Run a script in package.json /// Run a script in package.json
Run { Run {
/// The name of the script to run /// The name of the script to run
script_name: bool, script_name: Option<String>,
}, },
} }
pub(crate) trait Command {
async fn run(command: &Commands);
}
impl Command for Commands {
async fn run(&self) {
match self {
Commands::Run { .. } => {
run::Run::run(self).await;
}
}
}
}

8
src/command/run.rs Normal file
View file

@ -0,0 +1,8 @@
use super::{Command, Commands};
pub struct Run;
impl Command for Run {
async fn run(command: &Commands) {
}
}

View file

@ -1,10 +1,11 @@
use clap::Parser; use clap::Parser;
mod command; mod command;
use command::Cli; use command::{Cli, Command};
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let cli = Cli::parse(); let cli = Cli::parse();
cli.command.run().await;
println!("Hello, world!"); println!("Hello, world!");
} }