generated from ElnuDev/rust-project
init dyesub-cli
This commit is contained in:
parent
042a8719c8
commit
bdd378cc5f
7 changed files with 239 additions and 6 deletions
2
dyesub-cli/.gitignore
vendored
Normal file
2
dyesub-cli/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.json
|
||||
*.svg
|
11
dyesub-cli/Cargo.toml
Normal file
11
dyesub-cli/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "dyesub-cli"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = "4.3.23"
|
||||
clap_derive = "4.3.12"
|
||||
dyesub = { path = "../dyesub" }
|
31
dyesub-cli/src/main.rs
Normal file
31
dyesub-cli/src/main.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
#![feature(path_file_prefix)]
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
use clap_derive::Parser;
|
||||
use dyesub::Result;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
/// Input KLE JSON path
|
||||
input: PathBuf,
|
||||
/// Output SVG path
|
||||
#[arg(short, long)]
|
||||
output: Option<PathBuf>,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
let output = args.output.unwrap_or_else(|| {
|
||||
let mut path = args.input.clone();
|
||||
path.set_extension("svg");
|
||||
path
|
||||
});
|
||||
dyesub::render_file(
|
||||
&args.input,
|
||||
&output,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue