use clap::{Args, Subcommand};
#[derive(Args, Clone, Debug)]
pub struct ServiceArgs {
#[command(subcommand)]
pub action: ServiceAction,
}
#[derive(Subcommand, Clone, Debug)]
pub enum ServiceAction {
Install(ServiceInstallArgs),
Uninstall(ServiceUninstallArgs),
Start(ServiceScopeArgs),
Stop(ServiceScopeArgs),
Restart(ServiceScopeArgs),
Status(ServiceStatusArgs),
#[command(hide = true)]
Run(ServiceRunArgs),
}
impl ServiceAction {
pub fn user_scope(&self) -> bool {
match self {
Self::Install(a) => a.user,
Self::Uninstall(a) => a.user,
Self::Start(a) | Self::Stop(a) | Self::Restart(a) => a.user,
Self::Status(a) => a.user,
Self::Run(_) => false,
}
}
}
#[derive(Args, Clone, Debug)]
pub struct ServiceRunArgs {}
#[derive(Args, Clone, Debug)]
pub struct ServiceInstallArgs {
#[arg(long)]
pub user: bool,
#[arg(long, value_name = "NAME")]
pub service_user: Option<String>,
#[arg(long)]
pub now: bool,
#[arg(long)]
pub force: bool,
}
#[derive(Args, Clone, Debug)]
pub struct ServiceUninstallArgs {
#[arg(long)]
pub user: bool,
#[arg(long)]
pub force: bool,
}
#[derive(Args, Clone, Debug)]
pub struct ServiceScopeArgs {
#[arg(long)]
pub user: bool,
}
#[derive(Args, Clone, Debug)]
pub struct ServiceStatusArgs {
#[arg(long)]
pub user: bool,
#[arg(long)]
pub json: bool,
}