mirror of
https://github.com/SkyfallWasTaken/dinopkg.git
synced 2024-11-25 18:53:40 +00:00
Add run boilerplate
This commit is contained in:
parent
f9d384d350
commit
c20ee0e575
5 changed files with 17 additions and 27 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -186,7 +186,7 @@ dependencies = [
|
|||
"eyre",
|
||||
"indenter",
|
||||
"once_cell",
|
||||
"owo-colors",
|
||||
"owo-colors 3.5.0",
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
|
@ -197,7 +197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"owo-colors",
|
||||
"owo-colors 3.5.0",
|
||||
"tracing-core",
|
||||
"tracing-error",
|
||||
]
|
||||
|
@ -230,6 +230,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"owo-colors 4.0.0",
|
||||
"reqwest",
|
||||
"tokio",
|
||||
]
|
||||
|
@ -712,6 +713,12 @@ version = "3.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
|
||||
|
||||
[[package]]
|
||||
name = "owo-colors"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
|
|
|
@ -6,5 +6,6 @@ edition = "2021"
|
|||
[dependencies]
|
||||
clap = { version = "4.5.9", features = ["derive"] }
|
||||
color-eyre = "0.6.3"
|
||||
owo-colors = "4.0.0"
|
||||
reqwest = "0.12.5"
|
||||
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
|
||||
|
|
|
@ -6,28 +6,14 @@ pub mod run;
|
|||
#[command(version, about, long_about = None)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Commands,
|
||||
pub command: Command,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum Commands {
|
||||
pub enum Command {
|
||||
/// Run a script in package.json
|
||||
Run {
|
||||
/// The name of the script to run
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
use super::{Command, Commands};
|
||||
use super::Command;
|
||||
|
||||
pub struct Run;
|
||||
impl Command for Run {
|
||||
async fn run(command: &Commands) {
|
||||
|
||||
}
|
||||
}
|
||||
pub async fn run(script_name: Option<String>) {}
|
||||
|
|
|
@ -6,6 +6,7 @@ use command::{Cli, Command};
|
|||
#[tokio::main]
|
||||
async fn main() {
|
||||
let cli = Cli::parse();
|
||||
cli.command.run().await;
|
||||
println!("Hello, world!");
|
||||
match cli.command {
|
||||
Command::Run { script_name } => command::run::run(script_name).await,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue