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
package.json
package-lock.json
bun.lockb

View file

@ -1,10 +1,12 @@
use clap::{Parser, Subcommand};
pub mod run;
#[derive(Parser)]
#[command(version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
command: Commands,
pub command: Commands,
}
#[derive(Subcommand)]
@ -12,6 +14,20 @@ pub enum Commands {
/// Run a script in package.json
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;
mod command;
use command::Cli;
use command::{Cli, Command};
#[tokio::main]
async fn main() {
let cli = Cli::parse();
cli.command.run().await;
println!("Hello, world!");
}