Compare commits
2 commits
023427e3f9
...
e2d123cb0c
Author | SHA1 | Date | |
---|---|---|---|
e2d123cb0c | |||
1ae8995ac2 |
4 changed files with 74 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -206,6 +206,7 @@ name = "cli"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
|
"rmenu",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -5,4 +5,5 @@ 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,3 +1,73 @@
|
||||||
fn main() {
|
use std::num::ParseIntError;
|
||||||
println!("Hello, world!");
|
|
||||||
|
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() {
|
||||||
|
let args = Args::parse();
|
||||||
|
let cfg = create_config(args);
|
||||||
|
println!("{cfg:?}");
|
||||||
}
|
}
|
||||||
|
|
0
core/src/runner.rs
Normal file
0
core/src/runner.rs
Normal file
Loading…
Add table
Reference in a new issue