Skip to content

Commit

Permalink
Extract cargo-i18n binary to a separate crate
Browse files Browse the repository at this point in the history
- reduce dependencies on the main crate drastically
- import serde derive via serde import
  • Loading branch information
urkle committed Nov 14, 2023
1 parent 7958ec8 commit 50159cc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
17 changes: 1 addition & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,16 @@ repository = "https://github.com/longbridgeapp/rust-i18n"
version = "2.2.1"

[dependencies]
anyhow = {version = "1", optional = true}
clap = {version = "2.32", optional = true}
itertools = {version = "0.10.3", optional = true}
once_cell = "1.10.0"
quote = {version = "1", optional = true}
rust-i18n-extract = {path = "./crates/extract", version = "2.1.0", optional = true}
rust-i18n-support = {path = "./crates/support", version = "2.1.0"}
rust-i18n-macro = {path = "./crates/macro", version = "2.1.0"}
serde = "1"
serde_derive = "1"
toml = "0.7.4"

[dev-dependencies]
foo = {path = "examples/foo"}
criterion = "0.5"
lazy_static = "1"
serde_yaml = "0.8"

[features]
default = ["rust-i18n-extract", "clap", "anyhow", "quote", "itertools"]

[build-dependencies]
globwalk = "0.8.1"
regex = "1"
Expand All @@ -42,13 +31,9 @@ regex = "1"
name = "app"
test = true

[[bin]]
name = "cargo-i18n"
path = "src/main.rs"
required-features = ["default"]

[workspace]
members = [
"crates/cli",
"crates/extract",
"crates/support",
"crates/macro",
Expand Down
21 changes: 21 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
description = "cargo-i18n tool for the rust-i18n crate."
edition = "2021"
license = "MIT"
name = "rust-i18n-cli"
readme = "../../README.md"
repository = "https://github.com/longbridgeapp/rust-i18n"
version = "2.1.0"

[dependencies]
anyhow = "1"
clap = "2.32"
itertools = "0.10.3"
rust-i18n-support = { path = "../support", version = "2.1.0" }
rust-i18n-extract = { path = "../extract", version = "2.1.0" }
serde = { version = "1", features = ["derive"] }
toml = "0.7.4"

[[bin]]
name = "cargo-i18n"
path = "src/main.rs"
3 changes: 2 additions & 1 deletion src/config.rs → crates/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! See `Manifest::from_slice`.
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::fs;
use std::io;
use std::io::Read;
Expand Down Expand Up @@ -138,7 +139,7 @@ fn test_load_default() {
#[test]
fn test_load() {
let workdir = Path::new(env!["CARGO_MANIFEST_DIR"]);
let cargo_root = workdir.join("examples/foo");
let cargo_root = workdir.join("../../examples/foo");

let cfg = load(&cargo_root).unwrap();
assert_eq!(cfg.default_locale, "en");
Expand Down
3 changes: 0 additions & 3 deletions src/main.rs → crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ use std::{collections::HashMap, path::Path};
use rust_i18n_extract::{extractor, generator, iter};
mod config;

#[macro_use]
extern crate serde_derive;

const APP_NAME: &str = "rust-i18n";
const ABOUT: &str = r#"Rust I18n command for help you simply to extract all untranslated texts from soruce code.
Expand Down

0 comments on commit 50159cc

Please sign in to comment.