Skip to content

Commit

Permalink
Use clap for msvg (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Dec 29, 2023
1 parent 1f80424 commit 2111f06
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 22 deletions.
45 changes: 31 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ whiskers-derive = { path = "crates/whiskers-derive", version = "=0.4.0-alpha.0"
anyhow = "1"
bumpalo = "3.14.0" # avoid yanked 3.12.1, pulled by wasm-bindgen
camino = "1.1.0"
clap = "4.4.12"
convert_case = "0.6.0"
criterion = "0.5.1"
eframe = { version = "0.24.1", default-features = false, features = [
Expand Down
1 change: 1 addition & 0 deletions crates/msvg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ vsvg-viewer.workspace = true

anyhow.workspace = true
camino.workspace = true
clap = { workspace = true, features = ["derive"] }
egui.workspace = true
eframe.workspace = true
rayon.workspace = true
Expand Down
13 changes: 12 additions & 1 deletion crates/msvg/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use std::path::{Path, PathBuf};

use camino::Utf8PathBuf;
use clap::Parser;

use vsvg_viewer::show_with_viewer_app;

Expand Down Expand Up @@ -32,10 +33,20 @@ fn visit_dir(dir: &Path, paths: &mut Vec<Utf8PathBuf>) -> anyhow::Result<()> {
Ok(())
}

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
/// SVG files or directories
#[arg(required = true, num_args = 1..)]
paths: Vec<PathBuf>,
}

fn main() -> anyhow::Result<()> {
let args = Args::parse();

let mut svg_list = Vec::new();

for path in std::env::args().skip(1).map(PathBuf::from) {
for path in args.paths {
if path.is_dir() {
visit_dir(&path, &mut svg_list)?;
} else {
Expand Down
14 changes: 7 additions & 7 deletions crates/vsvg-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
egui.workspace = true
vsvg = { workspace = true, features = ["egui"] }
vsvg-viewer.workspace = true

clap = { workspace = true, features = ["cargo"] }
dhat = { version = "0.3.2", optional = true } # for heap profiling
eframe.workspace = true
serde.workspace = true
egui.workspace = true
kurbo.workspace = true
rand.workspace = true
rand_chacha.workspace = true
serde.workspace = true
tracing-subscriber = "0.3.16"
clap = { version = "4.1.6", features = ["cargo"]}
vsvg = { workspace = true, features = ["egui"] }
vsvg-viewer.workspace = true
dhat = { version = "0.3.2", optional = true } # for heap profiling



# for dhat-heap!!
Expand Down

0 comments on commit 2111f06

Please sign in to comment.