From 37e035147d1fb4d45ba64c07cbdf94d6b6addf77 Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Fri, 13 Oct 2023 12:00:16 -0300 Subject: [PATCH 01/12] Add shell completion and man page --- Cargo.lock | 27 +++++++++++++++++++++++++++ Cargo.toml | 19 ++++++++++++++++--- build.rs | 34 ++++++++++++++++++++++++++++++++++ src/cli.rs | 15 +++++++++++++++ src/main.rs | 16 +++------------- 5 files changed, 95 insertions(+), 16 deletions(-) create mode 100644 build.rs create mode 100644 src/cli.rs diff --git a/Cargo.lock b/Cargo.lock index 99bcc0dc..ffef2573 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -253,6 +253,15 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_complete" +version = "4.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7" +dependencies = [ + "clap", +] + [[package]] name = "clap_derive" version = "4.4.2" @@ -271,6 +280,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +[[package]] +name = "clap_mangen" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b44f35c514163027542f7147797ff930523eea288e03642727348ef1a9666f6b" +dependencies = [ + "clap", + "roff", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -1123,6 +1142,12 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "roff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" + [[package]] name = "roxmltree" version = "0.18.0" @@ -1261,6 +1286,8 @@ name = "svg2pdf" version = "0.9.0" dependencies = [ "clap", + "clap_complete", + "clap_mangen", "fontdb", "image", "miniz_oxide", diff --git a/Cargo.toml b/Cargo.toml index 119444ea..4e6bbe88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,10 @@ members = ["tests"] [workspace.package] version = "0.9.0" -authors = ["Martin Haug ", "Laurenz Stampfl "] +authors = [ + "Martin Haug ", + "Laurenz Stampfl ", +] edition = "2021" repository = "https://github.com/typst/svg2pdf" readme = "README.md" @@ -19,6 +22,7 @@ authors.workspace = true edition.workspace = true repository.workspace = true license.workspace = true +build = "build.rs" [features] default = ["image"] @@ -34,14 +38,23 @@ name = "svg2pdf" path = "src/main.rs" required-features = ["cli"] +[build-dependencies] +clap = { version = "4.4.2", features = ["derive", "string"] } +clap_complete = "4.4.3" +clap_mangen = "0.2.14" + [dependencies] miniz_oxide = "0.7" pdf-writer = "0.9" usvg = { version = "0.36", default-features = false } -image = { version = "0.24", default-features = false, features = ["jpeg", "png", "gif"], optional = true } +image = { version = "0.24", default-features = false, features = [ + "jpeg", + "png", + "gif", +], optional = true } termcolor = { version = "1", optional = true } clap = { version = "4.4.2", features = ["derive"], optional = true } -fontdb = { version = "0.15", optional= true } +fontdb = { version = "0.15", optional = true } [dev-dependencies] usvg = { version = "0.36.0" } diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..186ffcd2 --- /dev/null +++ b/build.rs @@ -0,0 +1,34 @@ +use std::{env, path::Path}; + +use clap::{CommandFactory, ValueEnum}; +use clap_complete::{generate_to, Shell}; + +mod args { + include!("src/cli.rs"); +} + +fn main() -> Result<(), std::io::Error> { + if !cfg!(feature = "cli") { + return Ok(()); + } + + let outdir_str = match env::var_os("OUT_DIR") { + None => return Ok(()), + Some(outdir) => outdir, + }; + + // Put the files in the same level as the binary (e.g. /target/debug folder) + let outdir_path = &Path::new(&outdir_str).ancestors().nth(3).unwrap(); + + let mut cmd = args::Args::command(); + + let man = clap_mangen::Man::new(cmd.clone()); + let mut manpage_file = std::fs::File::create(outdir_path.join("svg2pdf.1"))?; + man.render(&mut manpage_file)?; + + for shell in Shell::value_variants() { + generate_to(*shell, &mut cmd, "svg2pdf", &outdir_path).unwrap(); + } + + Ok(()) +} diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 00000000..905997c8 --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,15 @@ +use std::path::PathBuf; + +use clap::Parser; + +#[derive(Debug, Parser)] +#[clap(about, version)] +pub struct Args { + /// Path to read SVG file from. + pub input: PathBuf, + /// Path to write PDF file to. + pub output: Option, + /// The number of SVG pixels per PDF points. + #[clap(long, default_value = "72.0")] + pub dpi: f32, +} diff --git a/src/main.rs b/src/main.rs index c87c7925..7c3841a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use std::io::{self, Write}; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::process; use clap::Parser; @@ -8,17 +8,7 @@ use usvg::{TreeParsing, TreeTextToPath}; use svg2pdf::Options; -#[derive(Debug, Parser)] -#[clap(about, version)] -struct Args { - /// Path to read SVG file from. - input: PathBuf, - /// Path to write PDF file to. - output: Option, - /// The number of SVG pixels per PDF points. - #[clap(long, default_value = "72.0")] - dpi: f32, -} +mod cli; fn main() { if let Err(msg) = run() { @@ -28,7 +18,7 @@ fn main() { } fn run() -> Result<(), String> { - let args = Args::parse(); + let args = cli::Args::parse(); let name = Path::new(args.input.file_name().ok_or("Input path does not point to a file")?); From c98188a2dbd2499c758f0aae97a0f5f73805cb89 Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Mon, 16 Oct 2023 22:29:25 -0300 Subject: [PATCH 02/12] Fix clippy --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 186ffcd2..18df34ff 100644 --- a/build.rs +++ b/build.rs @@ -27,7 +27,7 @@ fn main() -> Result<(), std::io::Error> { man.render(&mut manpage_file)?; for shell in Shell::value_variants() { - generate_to(*shell, &mut cmd, "svg2pdf", &outdir_path).unwrap(); + generate_to(*shell, &mut cmd, "svg2pdf", outdir_path).unwrap(); } Ok(()) From 3e67710e60308eb50b975dd969d6fa40fcf8a131 Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Thu, 26 Oct 2023 21:11:59 -0300 Subject: [PATCH 03/12] Separate cli and lib into 2 crates --- Cargo.lock | 11 ++++ Cargo.toml | 51 ++----------------- crates/svg2pdf-cli/Cargo.toml | 38 ++++++++++++++ build.rs => crates/svg2pdf-cli/build.rs | 0 {src => crates/svg2pdf-cli/src}/cli.rs | 0 {src => crates/svg2pdf-cli/src}/main.rs | 0 crates/svg2pdf/Cargo.toml | 31 +++++++++++ {src => crates/svg2pdf/src}/lib.rs | 0 .../svg2pdf/src}/render/clip_path.rs | 0 .../svg2pdf/src}/render/gradient.rs | 0 {src => crates/svg2pdf/src}/render/group.rs | 0 {src => crates/svg2pdf/src}/render/image.rs | 0 {src => crates/svg2pdf/src}/render/mask.rs | 0 {src => crates/svg2pdf/src}/render/mod.rs | 0 {src => crates/svg2pdf/src}/render/path.rs | 0 {src => crates/svg2pdf/src}/render/pattern.rs | 0 {src => crates/svg2pdf/src}/util/allocate.rs | 0 {src => crates/svg2pdf/src}/util/context.rs | 0 {src => crates/svg2pdf/src}/util/defer.rs | 0 {src => crates/svg2pdf/src}/util/helper.rs | 0 {src => crates/svg2pdf/src}/util/mod.rs | 0 tests/Cargo.toml | 2 +- 22 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 crates/svg2pdf-cli/Cargo.toml rename build.rs => crates/svg2pdf-cli/build.rs (100%) rename {src => crates/svg2pdf-cli/src}/cli.rs (100%) rename {src => crates/svg2pdf-cli/src}/main.rs (100%) create mode 100644 crates/svg2pdf/Cargo.toml rename {src => crates/svg2pdf/src}/lib.rs (100%) rename {src => crates/svg2pdf/src}/render/clip_path.rs (100%) rename {src => crates/svg2pdf/src}/render/gradient.rs (100%) rename {src => crates/svg2pdf/src}/render/group.rs (100%) rename {src => crates/svg2pdf/src}/render/image.rs (100%) rename {src => crates/svg2pdf/src}/render/mask.rs (100%) rename {src => crates/svg2pdf/src}/render/mod.rs (100%) rename {src => crates/svg2pdf/src}/render/path.rs (100%) rename {src => crates/svg2pdf/src}/render/pattern.rs (100%) rename {src => crates/svg2pdf/src}/util/allocate.rs (100%) rename {src => crates/svg2pdf/src}/util/context.rs (100%) rename {src => crates/svg2pdf/src}/util/defer.rs (100%) rename {src => crates/svg2pdf/src}/util/helper.rs (100%) rename {src => crates/svg2pdf/src}/util/mod.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index ffef2573..02c413a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1284,6 +1284,16 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "svg2pdf" version = "0.9.0" +dependencies = [ + "image", + "miniz_oxide", + "pdf-writer", + "usvg", +] + +[[package]] +name = "svg2pdf-cli" +version = "0.8.0" dependencies = [ "clap", "clap_complete", @@ -1292,6 +1302,7 @@ dependencies = [ "image", "miniz_oxide", "pdf-writer", + "svg2pdf", "termcolor", "usvg", ] diff --git a/Cargo.toml b/Cargo.toml index 4e6bbe88..8a010d4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,7 @@ [workspace] -members = ["tests"] +members = ["crates/*", "tests"] +default-members = ["crates/svg2pdf-cli"] +resolver = "2" [workspace.package] version = "0.9.0" @@ -11,50 +13,3 @@ edition = "2021" repository = "https://github.com/typst/svg2pdf" readme = "README.md" license = "MIT OR Apache-2.0" - -[package] -name = "svg2pdf" -description = "Convert SVG files to PDFs." -categories = ["encoding", "graphics", "multimedia"] -keywords = ["svg", "pdf", "vector-graphics", "conversion"] -version.workspace = true -authors.workspace = true -edition.workspace = true -repository.workspace = true -license.workspace = true -build = "build.rs" - -[features] -default = ["image"] -image = ["dep:image"] -cli = ["dep:clap", "dep:termcolor", "usvg/text", "dep:fontdb"] - -[lib] -test = false -doctest = false - -[[bin]] -name = "svg2pdf" -path = "src/main.rs" -required-features = ["cli"] - -[build-dependencies] -clap = { version = "4.4.2", features = ["derive", "string"] } -clap_complete = "4.4.3" -clap_mangen = "0.2.14" - -[dependencies] -miniz_oxide = "0.7" -pdf-writer = "0.9" -usvg = { version = "0.36", default-features = false } -image = { version = "0.24", default-features = false, features = [ - "jpeg", - "png", - "gif", -], optional = true } -termcolor = { version = "1", optional = true } -clap = { version = "4.4.2", features = ["derive"], optional = true } -fontdb = { version = "0.15", optional = true } - -[dev-dependencies] -usvg = { version = "0.36.0" } diff --git a/crates/svg2pdf-cli/Cargo.toml b/crates/svg2pdf-cli/Cargo.toml new file mode 100644 index 00000000..3aa63a79 --- /dev/null +++ b/crates/svg2pdf-cli/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "svg2pdf-cli" +description = "The command line interface for svg2pdf." +categories = ["encoding", "graphics", "multimedia", "command-line-utilities"] +keywords = ["svg2pdf", "cli"] +version.workspace = true +authors.workspace = true +edition.workspace = true +repository.workspace = true +license.workspace = true +build = "build.rs" + +[[bin]] +name = "svg2pdf" +path = "src/main.rs" +test = false +doctest = false +bench = false +doc = false + +[dependencies] +svg2pdf = { path = "../svg2pdf" } +miniz_oxide = "0.7" +pdf-writer = "0.9" +usvg = { version = "0.36", default-features = false, features = ["text"] } +image = { version = "0.24", default-features = false, features = [ + "jpeg", + "png", + "gif", +] } +termcolor = { version = "1" } +clap = { version = "4.4.2", features = ["derive"] } +fontdb = { version = "0.15" } + +[build-dependencies] +clap = { version = "4.4.2", features = ["derive", "string"] } +clap_complete = "4.4.3" +clap_mangen = "0.2.14" \ No newline at end of file diff --git a/build.rs b/crates/svg2pdf-cli/build.rs similarity index 100% rename from build.rs rename to crates/svg2pdf-cli/build.rs diff --git a/src/cli.rs b/crates/svg2pdf-cli/src/cli.rs similarity index 100% rename from src/cli.rs rename to crates/svg2pdf-cli/src/cli.rs diff --git a/src/main.rs b/crates/svg2pdf-cli/src/main.rs similarity index 100% rename from src/main.rs rename to crates/svg2pdf-cli/src/main.rs diff --git a/crates/svg2pdf/Cargo.toml b/crates/svg2pdf/Cargo.toml new file mode 100644 index 00000000..00e70271 --- /dev/null +++ b/crates/svg2pdf/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "svg2pdf" +description = "Convert SVG files to PDFs." +categories = ["encoding", "graphics", "multimedia"] +keywords = ["svg", "pdf", "vector-graphics", "conversion"] +version.workspace = true +authors.workspace = true +edition.workspace = true +repository.workspace = true +license.workspace = true + +[lib] +doctest = false +bench = false + +[features] +default = ["image"] +image = ["dep:image"] + +[dependencies] +miniz_oxide = "0.7" +pdf-writer = "0.9" +usvg = { version = "0.36", default-features = false } +image = { version = "0.24", default-features = false, features = [ + "jpeg", + "png", + "gif", +], optional = true } + +[dev-dependencies] +usvg = { version = "0.36.0" } \ No newline at end of file diff --git a/src/lib.rs b/crates/svg2pdf/src/lib.rs similarity index 100% rename from src/lib.rs rename to crates/svg2pdf/src/lib.rs diff --git a/src/render/clip_path.rs b/crates/svg2pdf/src/render/clip_path.rs similarity index 100% rename from src/render/clip_path.rs rename to crates/svg2pdf/src/render/clip_path.rs diff --git a/src/render/gradient.rs b/crates/svg2pdf/src/render/gradient.rs similarity index 100% rename from src/render/gradient.rs rename to crates/svg2pdf/src/render/gradient.rs diff --git a/src/render/group.rs b/crates/svg2pdf/src/render/group.rs similarity index 100% rename from src/render/group.rs rename to crates/svg2pdf/src/render/group.rs diff --git a/src/render/image.rs b/crates/svg2pdf/src/render/image.rs similarity index 100% rename from src/render/image.rs rename to crates/svg2pdf/src/render/image.rs diff --git a/src/render/mask.rs b/crates/svg2pdf/src/render/mask.rs similarity index 100% rename from src/render/mask.rs rename to crates/svg2pdf/src/render/mask.rs diff --git a/src/render/mod.rs b/crates/svg2pdf/src/render/mod.rs similarity index 100% rename from src/render/mod.rs rename to crates/svg2pdf/src/render/mod.rs diff --git a/src/render/path.rs b/crates/svg2pdf/src/render/path.rs similarity index 100% rename from src/render/path.rs rename to crates/svg2pdf/src/render/path.rs diff --git a/src/render/pattern.rs b/crates/svg2pdf/src/render/pattern.rs similarity index 100% rename from src/render/pattern.rs rename to crates/svg2pdf/src/render/pattern.rs diff --git a/src/util/allocate.rs b/crates/svg2pdf/src/util/allocate.rs similarity index 100% rename from src/util/allocate.rs rename to crates/svg2pdf/src/util/allocate.rs diff --git a/src/util/context.rs b/crates/svg2pdf/src/util/context.rs similarity index 100% rename from src/util/context.rs rename to crates/svg2pdf/src/util/context.rs diff --git a/src/util/defer.rs b/crates/svg2pdf/src/util/defer.rs similarity index 100% rename from src/util/defer.rs rename to crates/svg2pdf/src/util/defer.rs diff --git a/src/util/helper.rs b/crates/svg2pdf/src/util/helper.rs similarity index 100% rename from src/util/helper.rs rename to crates/svg2pdf/src/util/helper.rs diff --git a/src/util/mod.rs b/crates/svg2pdf/src/util/mod.rs similarity index 100% rename from src/util/mod.rs rename to crates/svg2pdf/src/util/mod.rs diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 6903a466..3536ce11 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -29,7 +29,7 @@ test = false [dependencies] fontdb = "0.15" -svg2pdf = { path = ".." } +svg2pdf = { path = "../crates/svg2pdf" } usvg = "0.36.0" pdfium-render = "0.8.6" walkdir = "2.3.3" From db8db5fa4e13ec169079793b684aceee2b069029 Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Thu, 26 Oct 2023 21:19:56 -0300 Subject: [PATCH 04/12] Remove `--features cli` from CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c09ac57..4f1d219b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,6 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - - run: cargo clippy --all-targets --features cli + - run: cargo clippy --all-targets - run: cargo fmt --check --all - run: cargo doc --workspace --no-deps From 5694ee757b7213c4f5b54433495e31f8c079f9ad Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Thu, 26 Oct 2023 21:28:01 -0300 Subject: [PATCH 05/12] Update README CLI instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 883e919a..9290b832 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ std::fs::write("target/time_series.pdf", pdf)?; This crate also contains a command line interface. Install it by running the command below: ```bash -cargo install svg2pdf --features cli +cargo install svg2pdf-cli ``` You can then convert SVGs to PDFs by running commands like these: From 939a44aa47b7f7daed785c6fe9f9bca472c2e860 Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Thu, 26 Oct 2023 21:28:18 -0300 Subject: [PATCH 06/12] Build the lib by default --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8a010d4e..8c94fa08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = ["crates/*", "tests"] -default-members = ["crates/svg2pdf-cli"] +default-members = ["crates/svg2pdf"] resolver = "2" [workspace.package] From 004db6bcb4c7732b590e4b3e43fac89b52061db7 Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Thu, 26 Oct 2023 21:35:08 -0300 Subject: [PATCH 07/12] Remove conditional that is no longer useful --- crates/svg2pdf-cli/build.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/svg2pdf-cli/build.rs b/crates/svg2pdf-cli/build.rs index 18df34ff..1b9041ec 100644 --- a/crates/svg2pdf-cli/build.rs +++ b/crates/svg2pdf-cli/build.rs @@ -8,10 +8,6 @@ mod args { } fn main() -> Result<(), std::io::Error> { - if !cfg!(feature = "cli") { - return Ok(()); - } - let outdir_str = match env::var_os("OUT_DIR") { None => return Ok(()), Some(outdir) => outdir, From 9e3056e944d510c8702238f8b0bbf7f0c0493a6b Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Fri, 27 Oct 2023 08:11:42 -0300 Subject: [PATCH 08/12] Update CLI version --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 02c413a2..cac231ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1293,7 +1293,7 @@ dependencies = [ [[package]] name = "svg2pdf-cli" -version = "0.8.0" +version = "0.9.0" dependencies = [ "clap", "clap_complete", From 41758ea261bdf7710dd59e082f5aa39b0014a48b Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Mon, 6 Nov 2023 14:51:26 -0300 Subject: [PATCH 09/12] Put completions and man page in artifacts folder --- crates/svg2pdf-cli/build.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/svg2pdf-cli/build.rs b/crates/svg2pdf-cli/build.rs index 1b9041ec..c48f4f0e 100644 --- a/crates/svg2pdf-cli/build.rs +++ b/crates/svg2pdf-cli/build.rs @@ -13,17 +13,19 @@ fn main() -> Result<(), std::io::Error> { Some(outdir) => outdir, }; - // Put the files in the same level as the binary (e.g. /target/debug folder) + // Put the files in the artifacts folder (/target/artifacts) let outdir_path = &Path::new(&outdir_str).ancestors().nth(3).unwrap(); + let artifacts_path = outdir_path.join("artifacts"); + std::fs::create_dir_all(&artifacts_path)?; let mut cmd = args::Args::command(); let man = clap_mangen::Man::new(cmd.clone()); - let mut manpage_file = std::fs::File::create(outdir_path.join("svg2pdf.1"))?; + let mut manpage_file = std::fs::File::create(artifacts_path.join("svg2pdf.1"))?; man.render(&mut manpage_file)?; for shell in Shell::value_variants() { - generate_to(*shell, &mut cmd, "svg2pdf", outdir_path).unwrap(); + generate_to(*shell, &mut cmd, "svg2pdf", &artifacts_path).unwrap(); } Ok(()) From 305cc0ee4bb3f2ca48abf18981c8f21c973aeb7c Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Mon, 6 Nov 2023 15:01:05 -0300 Subject: [PATCH 10/12] Update crate default-member to be the CLI --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8c94fa08..8a010d4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = ["crates/*", "tests"] -default-members = ["crates/svg2pdf"] +default-members = ["crates/svg2pdf-cli"] resolver = "2" [workspace.package] From dd2f2d8f8f82924c514e56ea71e8654e4a996f0f Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Wed, 8 Nov 2023 15:54:45 -0300 Subject: [PATCH 11/12] Cargo.toml: Change to single line, newlines at EOF --- Cargo.toml | 6 ++---- crates/svg2pdf-cli/Cargo.toml | 9 +++------ crates/svg2pdf/Cargo.toml | 9 +++------ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8a010d4e..cbb64007 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,11 +5,9 @@ resolver = "2" [workspace.package] version = "0.9.0" -authors = [ - "Martin Haug ", - "Laurenz Stampfl ", -] +authors = ["Martin Haug ", "Laurenz Stampfl "] edition = "2021" repository = "https://github.com/typst/svg2pdf" readme = "README.md" license = "MIT OR Apache-2.0" + diff --git a/crates/svg2pdf-cli/Cargo.toml b/crates/svg2pdf-cli/Cargo.toml index 3aa63a79..1b87ad2f 100644 --- a/crates/svg2pdf-cli/Cargo.toml +++ b/crates/svg2pdf-cli/Cargo.toml @@ -23,11 +23,7 @@ svg2pdf = { path = "../svg2pdf" } miniz_oxide = "0.7" pdf-writer = "0.9" usvg = { version = "0.36", default-features = false, features = ["text"] } -image = { version = "0.24", default-features = false, features = [ - "jpeg", - "png", - "gif", -] } +image = { version = "0.24", default-features = false, features = ["jpeg", "png", "gif"] } termcolor = { version = "1" } clap = { version = "4.4.2", features = ["derive"] } fontdb = { version = "0.15" } @@ -35,4 +31,5 @@ fontdb = { version = "0.15" } [build-dependencies] clap = { version = "4.4.2", features = ["derive", "string"] } clap_complete = "4.4.3" -clap_mangen = "0.2.14" \ No newline at end of file +clap_mangen = "0.2.14" + diff --git a/crates/svg2pdf/Cargo.toml b/crates/svg2pdf/Cargo.toml index 00e70271..42607228 100644 --- a/crates/svg2pdf/Cargo.toml +++ b/crates/svg2pdf/Cargo.toml @@ -21,11 +21,8 @@ image = ["dep:image"] miniz_oxide = "0.7" pdf-writer = "0.9" usvg = { version = "0.36", default-features = false } -image = { version = "0.24", default-features = false, features = [ - "jpeg", - "png", - "gif", -], optional = true } +image = { version = "0.24", default-features = false, features = ["jpeg", "png", "gif"], optional = true } [dev-dependencies] -usvg = { version = "0.36.0" } \ No newline at end of file +usvg = { version = "0.36.0" } + From dc9798c7857a81e7165ac7eb40c3682ddd1dd86d Mon Sep 17 00:00:00 2001 From: Gabriel Lopes Rodrigues Date: Wed, 8 Nov 2023 16:03:57 -0300 Subject: [PATCH 12/12] Rename cli.rs to args.rs --- crates/svg2pdf-cli/build.rs | 2 +- crates/svg2pdf-cli/src/{cli.rs => args.rs} | 0 crates/svg2pdf-cli/src/main.rs | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) rename crates/svg2pdf-cli/src/{cli.rs => args.rs} (100%) diff --git a/crates/svg2pdf-cli/build.rs b/crates/svg2pdf-cli/build.rs index c48f4f0e..7ba59d35 100644 --- a/crates/svg2pdf-cli/build.rs +++ b/crates/svg2pdf-cli/build.rs @@ -4,7 +4,7 @@ use clap::{CommandFactory, ValueEnum}; use clap_complete::{generate_to, Shell}; mod args { - include!("src/cli.rs"); + include!("src/args.rs"); } fn main() -> Result<(), std::io::Error> { diff --git a/crates/svg2pdf-cli/src/cli.rs b/crates/svg2pdf-cli/src/args.rs similarity index 100% rename from crates/svg2pdf-cli/src/cli.rs rename to crates/svg2pdf-cli/src/args.rs diff --git a/crates/svg2pdf-cli/src/main.rs b/crates/svg2pdf-cli/src/main.rs index 7c3841a7..77ff1f02 100644 --- a/crates/svg2pdf-cli/src/main.rs +++ b/crates/svg2pdf-cli/src/main.rs @@ -8,7 +8,7 @@ use usvg::{TreeParsing, TreeTextToPath}; use svg2pdf::Options; -mod cli; +mod args; fn main() { if let Err(msg) = run() { @@ -18,7 +18,7 @@ fn main() { } fn run() -> Result<(), String> { - let args = cli::Args::parse(); + let args = args::Args::parse(); let name = Path::new(args.input.file_name().ok_or("Input path does not point to a file")?);