Files
mytheclipse/crates/mytheclipse-cli/src/builder.rs
T
asepharyana 8106f8943e feat: add 4 new crates (queue, tracing, http, cli) + enhancements to existing crates
New crates:
- mytheclipse-queue: unified job queue with WorkerPool, retry/backoff, DLQ
  Backends: in-memory (default), Redis, NATS, PostgreSQL
- mytheclipse-tracing: tracing subscriber layers with env filter + OTLP/Jaeger export
- mytheclipse-http: HTTP client/server with timeout + tracing, axum server
- mytheclipse-cli: CLI framework with clap derive, built-in subcommands

Enhancements to existing crates:
- mytheclipse-core: SemaphorePool, LeaderElection, HealthRegistry/HealthCheck
- mytheclipse-cache: AutoRefreshCache (bg refresh on miss), CacheMetrics
- mytheclipse-config: ConfigSchema for JSON Schema generation
- mytheclipse-storage: MultipartUploadDriver trait
- mytheclipse-crypto: PASETO v4.local token support

All features compile with --all-features; tests + clippy pass clean.
2026-08-29 16:05:02 +07:00

58 lines
1.2 KiB
Rust

//! Clap-based CLI builder implementation.
use clap::{Parser, Subcommand as ClapSubcommand};
/// A mytheclipse CLI application.
#[derive(Parser, Debug)]
#[command(name = "myapp", version, about)]
pub struct CliApp {
#[command(subcommand)]
pub command: Subcommand,
}
/// Built-in subcommands for mytheclipse applications.
#[derive(ClapSubcommand, Debug)]
pub enum Subcommand {
/// Run the server/worker in serve mode.
Serve,
/// Run background job workers.
Worker {
/// Topic(s) to consume from.
topics: Vec<String>,
},
/// Run database migrations.
Migrate,
/// Check service health.
Health,
/// Print version information.
Version,
}
/// Builder for CliApp with configuration.
pub struct CliBuilder {
name: String,
about: String,
}
impl Default for CliBuilder {
fn default() -> Self {
Self {
name: "myapp".to_string(),
about: "A mytheclipse application".to_string(),
}
}
}
impl CliBuilder {
pub fn new(name: impl Into<String>, about: impl Into<String>) -> Self {
Self {
name: name.into(),
about: about.into(),
}
}
pub fn build(self) -> CliApp {
CliApp::parse()
}
}