Take config path as input

This commit is contained in:
Andras Schmelczer 2025-03-24 21:57:56 +00:00
parent 958af89116
commit baba8f82bf
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
6 changed files with 56 additions and 9 deletions

View 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)
}
}