Compare commits
No commits in common. "e2d123cb0c9b99678e6b049c79af46c4a7335a0b" and "023427e3f92575c5a87ee38bbef295ba63347571" have entirely different histories.
e2d123cb0c
...
023427e3f9
4 changed files with 1 additions and 73 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -206,7 +206,6 @@ name = "cli"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"rmenu",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -5,5 +5,4 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.27", features = ["derive"] }
|
clap = { version = "4.5.27", features = ["derive"] }
|
||||||
rmenu = { version = "0.1.0", path = "../core" }
|
|
||||||
|
|
||||||
|
|
|
@ -1,73 +1,3 @@
|
||||||
use std::num::ParseIntError;
|
|
||||||
|
|
||||||
use clap::Parser;
|
|
||||||
|
|
||||||
macro_rules! set_opt {
|
|
||||||
($arg:expr, $cfg:expr) => {
|
|
||||||
if arg.is_some() {
|
|
||||||
cfg = arg.unwrap();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! set_color {
|
|
||||||
($fg:expr, $bg:expr, $cfg:expr) => {
|
|
||||||
set_opt!(bg, cfg.0);
|
|
||||||
set_opt!(fg, cfg.1);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_number(n: &str) -> Result<usize, ParseIntError> {
|
|
||||||
match n.strip_prefix("0x") {
|
|
||||||
Some(value) => usize::from_str_radix(value, 16),
|
|
||||||
None => usize::from_str_radix(n, 10),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_config(args: Args) -> Config {
|
|
||||||
let cfg = Config::default();
|
|
||||||
|
|
||||||
set_opt!(args.bottom, cfg.bottom);
|
|
||||||
set_opt!(args.height, cfg.height);
|
|
||||||
set_opt!(args.padding, cfg.padding);
|
|
||||||
set_opt!(args.lines, cfg.lines);
|
|
||||||
set_opt!(args.line_height, cfg.line_height);
|
|
||||||
set_opt!(args.font_family, cfg.font_family);
|
|
||||||
set_opt!(args.font_size, cfg.font_size);
|
|
||||||
set_opt!(args.language, cfg.language);
|
|
||||||
set_color!(args.normal_bg, args.normal_fg, cfg.normal_color);
|
|
||||||
set_color!(args.prompt_bg, args.prompt_fg, cfg.prompt_color);
|
|
||||||
set_color!(args.selection_bg, args.selection_fg, cfg.selection_color);
|
|
||||||
|
|
||||||
cfg
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Parser)]
|
|
||||||
#[command(version, about, long_about = None)]
|
|
||||||
struct Args {
|
|
||||||
// transform
|
|
||||||
pub bottom: Option<bool>,
|
|
||||||
pub height: Option<usize>,
|
|
||||||
pub padding: Option<usize>,
|
|
||||||
pub lines: Option<usize>,
|
|
||||||
pub line_height: Option<usize>,
|
|
||||||
|
|
||||||
// typography
|
|
||||||
pub font_family: Option<String>,
|
|
||||||
pub font_size: Option<usize>,
|
|
||||||
pub language: Option<String>,
|
|
||||||
|
|
||||||
// color
|
|
||||||
pub normal_fg: Option<String>,
|
|
||||||
pub normal_bg: Option<String>,
|
|
||||||
pub prompt_fg: Option<String>,
|
|
||||||
pub prompt_bg: Option<String>,
|
|
||||||
pub selection_fg: Option<String>,
|
|
||||||
pub selection_bg: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = Args::parse();
|
println!("Hello, world!");
|
||||||
let cfg = create_config(args);
|
|
||||||
println!("{cfg:?}");
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue