This commit is contained in:
Gvidas Juknevičius 2024-12-04 18:24:27 +02:00
parent cef329fa00
commit 93d42b1189
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
5 changed files with 5043 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

4931
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

14
Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "dp"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.94"
clap = { version = "4.5.22", features = ["derive"] }
eframe = "0.29.1"
egui = { version = "0.29.1", features = ["color-hex"] }
egui_extras = { version = "0.29.1", features = ["all_loaders"] }
env_logger = "0.11.5"
log = "0.4.22"
reqwest = { version = "0.12.9", features = ["blocking"] }

55
src/gui/mod.rs Normal file
View File

@ -0,0 +1,55 @@
struct Gui {
name: String,
age: u32,
}
impl Default for Gui {
fn default() -> Self {
Self {
name: "Arthur".to_owned(),
age: 42,
}
}
}
impl eframe::App for Gui {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
ui.horizontal(|ui| {
let name_label = ui.label("Your name: ");
ui.text_edit_singleline(&mut self.name)
.labelled_by(name_label.id);
});
ui.add(egui::Slider::new(&mut self.age, 0..=120).text("age"));
if ui.button("Increment").clicked() {
self.age += 1;
}
ui.label(format!("Hello '{}', age {}", self.name, self.age));
// ui.image(egui::include_image!(
// "../../../crates/egui/assets/ferris.png"
// ));
});
}
}
pub fn start_gui() {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
..Default::default()
};
eframe::run_native(
"My egui App",
options,
Box::new(|cc| {
// This gives us image support:
egui_extras::install_image_loaders(&cc.egui_ctx);
Ok(Box::<Gui>::default())
}),
).unwrap();
}

42
src/main.rs Normal file
View File

@ -0,0 +1,42 @@
use clap::Parser;
mod gui;
#[derive(Debug, Parser)]
pub struct CliArgs {
#[arg(long, short)]
debug: bool,
#[clap(subcommand)]
arg: Arg
}
#[derive(Debug, clap::Subcommand)]
enum Arg {
Gui,
Install {
},
Query {
},
List {
},
}
fn main() {
let cliargs = CliArgs::parse();
env_logger::builder()
.filter_level(log::LevelFilter::Info)
.parse_default_env()
.format_timestamp(None)
.init();
log::debug!("{cliargs:?}");
match cliargs.arg {
Arg::Gui => gui::start_gui(),
_ => todo!()
}
}