34 lines
656 B
Rust
34 lines
656 B
Rust
use clap::{Parser, Subcommand};
|
|
|
|
mod commands;
|
|
mod config;
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(name = "watchdog")]
|
|
#[command(about = "A lightweight watchdog service", long_about = None)]
|
|
struct Cli {
|
|
#[command(subcommand)]
|
|
command: Command,
|
|
}
|
|
|
|
#[derive(Subcommand, Debug)]
|
|
enum Command {
|
|
Run,
|
|
Check,
|
|
Start,
|
|
CheckEnv,
|
|
}
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let cli = Cli::parse();
|
|
|
|
match cli.command {
|
|
Command::Run => commands::run(),
|
|
Command::Check => commands::check()?,
|
|
Command::Start => commands::start(),
|
|
Command::CheckEnv => commands::check_env()?,
|
|
}
|
|
|
|
Ok(())
|
|
}
|