use clap::{Args, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Args)]
pub struct PluginArgs {
#[command(subcommand)]
pub command: PluginCommand,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, ValueEnum)]
pub enum PluginScopeArg {
Project,
Global,
}
#[derive(Args, Debug, Clone)]
#[command(
after_long_help = "Examples:\n ralph plugin init acme.super_runner\n ralph plugin init acme.super_runner --with-runner\n ralph plugin init acme.super_runner --with-processor\n ralph plugin init acme.super_runner --scope global\n ralph plugin init acme.super_runner --dry-run\n"
)]
pub struct PluginInitArgs {
#[arg(value_name = "PLUGIN_ID")]
pub id: String,
#[arg(long, value_enum, default_value = "project")]
pub scope: PluginScopeArg,
#[arg(long, value_name = "DIR")]
pub path: Option<PathBuf>,
#[arg(long)]
pub name: Option<String>,
#[arg(long, default_value = "0.1.0")]
pub version: String,
#[arg(long)]
pub description: Option<String>,
#[arg(long)]
pub with_runner: bool,
#[arg(long)]
pub with_processor: bool,
#[arg(long)]
pub dry_run: bool,
#[arg(long)]
pub force: bool,
}
#[derive(Subcommand)]
pub enum PluginCommand {
#[command(after_long_help = "Examples:\n ralph plugin list\n ralph plugin list --json\n")]
List {
#[arg(long)]
json: bool,
},
#[command(
after_long_help = "Examples:\n ralph plugin validate\n ralph plugin validate --id acme.super_runner\n"
)]
Validate {
#[arg(long)]
id: Option<String>,
},
#[command(
after_long_help = "Examples:\n ralph plugin install ./my-plugin --scope project\n ralph plugin install ./my-plugin --scope global\n\nNotes:\n - Install does not enable the plugin. Enable via config.plugins.plugins.<id>.enabled=true\n"
)]
Install {
source: String,
#[arg(long, value_enum, default_value = "project")]
scope: PluginScopeArg,
},
#[command(
after_long_help = "Examples:\n ralph plugin uninstall acme.super_runner --scope project\n"
)]
Uninstall {
id: String,
#[arg(long, value_enum, default_value = "project")]
scope: PluginScopeArg,
},
#[command(
after_long_help = "Examples:\n ralph plugin init acme.super_runner\n ralph plugin init acme.super_runner --with-runner\n ralph plugin init acme.super_runner --with-processor\n ralph plugin init acme.super_runner --scope global\n ralph plugin init acme.super_runner --dry-run\n"
)]
Init(PluginInitArgs),
}