use std::path::PathBuf;
use clap::{Parser, Subcommand};
use crate::commands::alias::shell::Shell;
#[derive(Debug, Parser)]
#[command(
name = "lightshuttle",
version,
about = "Lightweight dev orchestrator for polyglot teams"
)]
pub struct Cli {
#[arg(long, short = 'f', global = true)]
pub(crate) file: Option<PathBuf>,
#[command(subcommand)]
pub(crate) command: Command,
}
#[derive(Debug, Subcommand)]
pub(crate) enum Command {
#[command(after_long_help = "Examples:
# Boot the stack defined by the nearest manifest
lightshuttle up
# Use an explicit manifest and a custom control plane port
lightshuttle -f stack.yaml up --control-port 8080
# Run without the bundled OpenTelemetry collector
lightshuttle up --no-otel")]
Up {
#[arg(long, default_value = "10s")]
grace: humantime::Duration,
#[arg(long, value_parser = clap::value_parser!(u16).range(1..))]
control_port: Option<u16>,
#[arg(long)]
no_otel: bool,
#[arg(long)]
env_file: Option<PathBuf>,
},
#[command(after_long_help = "Examples:
# Stop every container, allowing 30s for graceful shutdown
lightshuttle down --grace 30s")]
Down {
#[arg(long, default_value = "10s")]
grace: humantime::Duration,
},
#[command(after_long_help = "Examples:
# List managed resources and their status
lightshuttle ps")]
Ps,
#[command(after_long_help = "Examples:
# Show the recent logs of the `api` resource
lightshuttle logs api
# Follow the log stream until interrupted
lightshuttle logs api --follow")]
Logs {
resource: String,
#[arg(long, short = 'f')]
follow: bool,
},
#[command(after_long_help = "Examples:
# Validate the manifest
lightshuttle validate
# Fail on warnings, for continuous integration
lightshuttle validate --strict")]
Validate {
#[arg(long)]
strict: bool,
},
#[command(after_long_help = "Examples:
# Print the resolved manifest as YAML
lightshuttle manifest")]
Manifest,
#[command(after_long_help = "Examples:
# Restart the `api` resource and wait for it to become healthy again
lightshuttle restart api
# Request the restart and return immediately
lightshuttle restart api --detach")]
Restart {
resource: String,
#[arg(long)]
detach: bool,
},
#[command(after_long_help = "Examples:
# Install the `lsh` alias into your shell's startup file
lightshuttle alias install
# Preview what install would do, without writing anything
lightshuttle alias check
# Remove the alias
lightshuttle alias uninstall")]
Alias {
#[command(subcommand)]
action: AliasAction,
},
#[command(after_long_help = "Examples:
# Generate a docker-compose.yml under ./export/compose
lightshuttle export compose
# Generate Kubernetes manifests into a chosen directory, overwriting it
lightshuttle export kubernetes --output ./k8s --force")]
Export {
target: ExportTarget,
#[arg(long, short = 'o')]
output: Option<PathBuf>,
#[arg(long)]
force: bool,
},
#[command(after_long_help = "Examples:
# Report which ${env.*} variables are set, defaulted, or missing
lightshuttle secrets check
# Check against a specific .env file
lightshuttle secrets check --env-file .env.prod")]
Secrets {
#[command(subcommand)]
action: SecretsAction,
},
}
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
pub(crate) enum ExportTarget {
Compose,
Kubernetes,
Helm,
}
#[derive(Debug, Subcommand)]
pub(crate) enum SecretsAction {
Check {
#[arg(long)]
env_file: Option<PathBuf>,
},
}
#[derive(Debug, Subcommand)]
pub(crate) enum AliasAction {
Install {
#[arg(long)]
shell: Option<Shell>,
#[arg(long)]
yes: bool,
},
Check {
#[arg(long)]
shell: Option<Shell>,
},
Uninstall {
#[arg(long)]
shell: Option<Shell>,
#[arg(long)]
yes: bool,
},
}