34 lines
929 B
Rust
34 lines
929 B
Rust
use clap::{Args, Parser, Subcommand};
|
|
use thiserror::Error;
|
|
use tracing::Level;
|
|
|
|
#[derive(Debug, Parser)]
|
|
#[clap(version, about)]
|
|
pub struct CommandArgs {
|
|
/// The path to a TOML or JSON configuration to use. This will me merged with all other configuration sources, taking priority over other files but not environment variables
|
|
#[arg(short, long)]
|
|
pub config: Option<String>,
|
|
|
|
#[clap(subcommand)]
|
|
pub action: ActionType,
|
|
}
|
|
|
|
#[derive(Debug, Subcommand)]
|
|
pub enum ActionType {
|
|
/// Run the daemon and listen for requests
|
|
Serve(ServeAction),
|
|
}
|
|
|
|
#[derive(Debug, Args)]
|
|
pub struct ServeAction {
|
|
/// The log level to use for the server
|
|
#[arg(short, long, default_value_t = Level::WARN)]
|
|
pub log_level: Level,
|
|
}
|
|
|
|
#[derive(Error, Debug)]
|
|
pub enum ArgsError {
|
|
#[error("the file extension of the provided config file is not one of .json or .toml")]
|
|
InvalidConfigExtension(Option<String>),
|
|
}
|