Take config path as input
This commit is contained in:
parent
958af89116
commit
baba8f82bf
6 changed files with 56 additions and 9 deletions
38
backend/sync_server/src/cli/args.rs
Normal file
38
backend/sync_server/src/cli/args.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
use std::ffi::OsString;
|
||||
|
||||
use clap::{Parser, ValueEnum};
|
||||
|
||||
/// Simple program to greet a person
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
#[arg(
|
||||
long,
|
||||
require_equals = true,
|
||||
value_name = "WHEN",
|
||||
num_args = 0..=1,
|
||||
default_value_t = ColorWhen::Auto,
|
||||
default_missing_value = "always",
|
||||
value_enum
|
||||
)]
|
||||
pub color: ColorWhen,
|
||||
|
||||
#[arg(last = true)]
|
||||
pub config_path: Option<OsString>,
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ColorWhen {
|
||||
Always,
|
||||
Auto,
|
||||
Never,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ColorWhen {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.to_possible_value()
|
||||
.expect("no values are skipped")
|
||||
.get_name()
|
||||
.fmt(f)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue