You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
50 lines
1.1 KiB
2 years ago
|
use clap::{AppSettings, Parser, ValueEnum};
|
||
2 years ago
|
use std::fmt::{Display, Formatter};
|
||
|
|
||
|
#[derive(Parser)]
|
||
2 years ago
|
#[clap(name = "cargo")]
|
||
|
#[clap(bin_name = "cargo")]
|
||
|
pub enum Cargo {
|
||
|
#[clap(name = "3ds")]
|
||
|
Input(Input),
|
||
|
}
|
||
|
|
||
|
#[derive(clap::Args)]
|
||
|
#[clap(about)]
|
||
2 years ago
|
#[clap(global_setting(AppSettings::AllowLeadingHyphen))]
|
||
2 years ago
|
pub struct Input {
|
||
2 years ago
|
#[clap(value_enum)]
|
||
2 years ago
|
pub cmd: CargoCommand,
|
||
|
pub cargo_opts: Vec<String>,
|
||
|
}
|
||
|
|
||
2 years ago
|
#[derive(ValueEnum, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||
2 years ago
|
pub enum CargoCommand {
|
||
|
Build,
|
||
|
Run,
|
||
|
Test,
|
||
|
Check,
|
||
|
Clippy,
|
||
|
}
|
||
|
|
||
|
impl CargoCommand {
|
||
|
pub fn should_build_3dsx(&self) -> bool {
|
||
|
matches!(
|
||
|
self,
|
||
|
CargoCommand::Build | CargoCommand::Run | CargoCommand::Test
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl Display for CargoCommand {
|
||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||
|
match self {
|
||
|
CargoCommand::Build => write!(f, "build"),
|
||
|
CargoCommand::Run => write!(f, "run"),
|
||
|
CargoCommand::Test => write!(f, "test"),
|
||
|
CargoCommand::Check => write!(f, "check"),
|
||
|
CargoCommand::Clippy => write!(f, "clippy"),
|
||
|
}
|
||
|
}
|
||
|
}
|