Add 'run' subcommand
For future extensibility
This commit is contained in:
parent
aecf9509f5
commit
a52567330a
|
@ -85,4 +85,4 @@ updater-server=http://invalid.example
|
||||||
### Running factoriauth
|
### Running factoriauth
|
||||||
|
|
||||||
Either use `cargo install --path .` and follow its instructions for how to update `$PATH`, then run
|
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`.
|
||||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -35,7 +35,7 @@ use std::{env, path::PathBuf, sync::Arc};
|
||||||
use auth::{
|
use auth::{
|
||||||
AuthenticationBackend, ServerPadlockGenerator, UserAuthenticator, UserServerKeyGenerator,
|
AuthenticationBackend, ServerPadlockGenerator, UserAuthenticator, UserServerKeyGenerator,
|
||||||
};
|
};
|
||||||
use clap::Parser;
|
use clap::{Parser, Subcommand};
|
||||||
use color_eyre::{eyre::Context, Result};
|
use color_eyre::{eyre::Context, Result};
|
||||||
use config::Config;
|
use config::Config;
|
||||||
use db::{Database, SqliteDatabase};
|
use db::{Database, SqliteDatabase};
|
||||||
|
@ -92,11 +92,20 @@ async fn load_config(path: &str) -> Result<Config> {
|
||||||
Ok(toml::from_str(&content)?)
|
Ok(toml::from_str(&content)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Subcommand)]
|
||||||
|
enum Command {
|
||||||
|
/// Run factoriauth
|
||||||
|
Run,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Path to the configuration file.
|
/// Path to the configuration file.
|
||||||
#[arg(short, long, default_value = "config.toml")]
|
#[arg(short, long, default_value = "config.toml")]
|
||||||
config: String,
|
config: String,
|
||||||
|
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: Command,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -104,6 +113,10 @@ struct Args {
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
|
match args.command {
|
||||||
|
Command::Run => {}
|
||||||
|
}
|
||||||
|
|
||||||
init().context("Failed to initialize tracing")?;
|
init().context("Failed to initialize tracing")?;
|
||||||
|
|
||||||
let config = load_config(&args.config).await.with_context(|| {
|
let config = load_config(&args.config).await.with_context(|| {
|
||||||
|
|
Loading…
Reference in a new issue