mod build;
mod common;
mod config;
mod deploy;
mod generate;
mod help;
mod lint;
mod list;
mod manifest;
mod run;
mod source;
mod testing;
mod tools;
#[derive(clap::Parser)]
#[command(version, about)]
#[command(propagate_version = true)]
#[command(name = "gears")]
pub struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(clap::Subcommand)]
#[command(disable_help_subcommand = true)]
pub enum Commands {
Generate(generate::GenerateArgs),
New(generate::WorkspaceArgs),
Config(Box<config::ConfigArgs>),
Src(source::SourceArgs),
Help(help::HelpArgs),
Lint(lint::LintArgs),
#[command(name = "ls")]
List(list::ListArgs),
Manifest(manifest::ManifestArgs),
Test(testing::TestArgs),
Tools(tools::ToolsArgs),
Run(run::RunArgs),
Build(build::BuildArgs),
Deploy(deploy::DeployArgs),
}
impl Cli {
pub fn run(self) -> anyhow::Result<()> {
cargo_gears_core::GearsCommand::from(self).run()
}
}
impl From<Cli> for cargo_gears_core::GearsCommand {
fn from(cli: Cli) -> Self {
match cli.command {
Commands::Generate(generate) => Self::Generate(generate.into()),
Commands::New(workspace) => {
Self::Generate(cargo_gears_core::generate::GenerateParams {
command: cargo_gears_core::generate::GenerateCommand::Workspace(
workspace.into(),
),
})
}
Commands::Config(config) => Self::Config((*config).into()),
Commands::Src(src) => Self::Src(src.into()),
Commands::Help(help) => help.into(),
Commands::Lint(lint) => Self::Lint(lint.into()),
Commands::List(list) => Self::List(list.into()),
Commands::Manifest(manifest) => Self::Manifest(manifest.into()),
Commands::Test(test) => Self::Test(test.into()),
Commands::Tools(tools) => Self::Tools(tools.into()),
Commands::Run(run) => Self::Run(run.into()),
Commands::Build(build) => Self::Build(build.into()),
Commands::Deploy(deploy) => Self::Deploy(deploy.into()),
}
}
}