From a52567330ac8696855340fb2bf8b839a042ef853 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Tue, 20 Feb 2024 21:59:43 +0000 Subject: [PATCH] Add 'run' subcommand For future extensibility --- README.md | 2 +- src/main.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3784518..6219bde 100644 --- a/README.md +++ b/README.md @@ -85,4 +85,4 @@ updater-server=http://invalid.example ### Running factoriauth Either use `cargo install --path .` and follow its instructions for how to update `$PATH`, then run -`factoriauth`, or run the program straight from the repository: `cargo run`. +`factoriauth run`, or run the program straight from the repository: `cargo run -- run`. diff --git a/src/main.rs b/src/main.rs index 9241dda..f98d666 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,7 @@ use std::{env, path::PathBuf, sync::Arc}; use auth::{ AuthenticationBackend, ServerPadlockGenerator, UserAuthenticator, UserServerKeyGenerator, }; -use clap::Parser; +use clap::{Parser, Subcommand}; use color_eyre::{eyre::Context, Result}; use config::Config; use db::{Database, SqliteDatabase}; @@ -92,11 +92,20 @@ async fn load_config(path: &str) -> Result { Ok(toml::from_str(&content)?) } +#[derive(Debug, Clone, Subcommand)] +enum Command { + /// Run factoriauth + Run, +} + #[derive(Debug, Clone, Parser)] struct Args { /// Path to the configuration file. #[arg(short, long, default_value = "config.toml")] config: String, + + #[command(subcommand)] + command: Command, } #[tokio::main] @@ -104,6 +113,10 @@ struct Args { async fn main() -> Result<()> { let args = Args::parse(); + match args.command { + Command::Run => {} + } + init().context("Failed to initialize tracing")?; let config = load_config(&args.config).await.with_context(|| {