misc: initial commit
This commit is contained in:
64
src/cli.rs
Normal file
64
src/cli.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
use clap::{Args, Parser, Subcommand, builder::styling};
|
||||
|
||||
const STYLES: styling::Styles = styling::Styles::styled()
|
||||
.header(styling::AnsiColor::Green.on_default().bold())
|
||||
.usage(styling::AnsiColor::Green.on_default().bold())
|
||||
.literal(styling::AnsiColor::Blue.on_default().bold())
|
||||
.placeholder(styling::AnsiColor::Cyan.on_default());
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "pgx")]
|
||||
#[command(about = "Project-scoped PostgreSQL instance manager", long_about = None)]
|
||||
#[command(version)]
|
||||
#[command(styles = STYLES)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Commands,
|
||||
|
||||
#[arg(short, long, global = true)]
|
||||
pub verbose: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, clap::ValueEnum)]
|
||||
pub enum ConnectionFormat {
|
||||
/// Human-readable text format
|
||||
Text,
|
||||
/// JSON format
|
||||
Json,
|
||||
/// Environment variable format
|
||||
Env,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum ControlCommands {
|
||||
/// Start postgres instance
|
||||
Start,
|
||||
/// Stop postgres instance
|
||||
Stop,
|
||||
/// Restart postgres instance
|
||||
Restart,
|
||||
/// (WARNING!) Destroy postgres instance
|
||||
Destroy,
|
||||
/// Status of instance
|
||||
Status,
|
||||
/// View logs produced by postgres
|
||||
Logs { follow: bool },
|
||||
/// (Sensitive) get connection details
|
||||
Connection { format: ConnectionFormat },
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum Commands {
|
||||
/// Create a new project, or initialize instance for existing one
|
||||
Init,
|
||||
/// Create a new project, or initialize instance for existing one
|
||||
Sync,
|
||||
|
||||
/// Start the PostgreSQL container for the current project
|
||||
Instance {
|
||||
// Name of the instance you want to control. Defaults to current project
|
||||
name: Option<String>,
|
||||
#[command(subcommand)]
|
||||
cmd: ControlCommands,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user