mirror of
https://github.com/lise-henry/crowbook
synced 2024-05-12 14:46:04 +02:00
Use rust-i18n instead of crowbook-intl
This commit is contained in:
parent
68132165e0
commit
0ff24f94f4
|
@ -41,6 +41,15 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.3.2"
|
||||
|
@ -90,6 +99,23 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.75"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.19",
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "0.1.8"
|
||||
|
@ -147,6 +173,16 @@ version = "2.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.13.0"
|
||||
|
@ -188,6 +224,21 @@ dependencies = [
|
|||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags 1.3.2",
|
||||
"strsim 0.8.0",
|
||||
"textwrap 0.11.0",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.3.21"
|
||||
|
@ -208,7 +259,7 @@ dependencies = [
|
|||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
"strsim 0.10.0",
|
||||
"terminal_size",
|
||||
]
|
||||
|
||||
|
@ -251,7 +302,7 @@ version = "0.18.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "482aa5695bca086022be453c700a40c02893f1ba7098a2c88351de55341ae894"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap 4.3.21",
|
||||
"entities",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
|
@ -340,7 +391,7 @@ name = "crowbook"
|
|||
version = "0.17.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"clap",
|
||||
"clap 4.3.21",
|
||||
"comrak",
|
||||
"console",
|
||||
"crowbook-intl",
|
||||
|
@ -356,10 +407,11 @@ dependencies = [
|
|||
"numerals",
|
||||
"punkt",
|
||||
"rayon",
|
||||
"rust-i18n",
|
||||
"simplelog",
|
||||
"syntect",
|
||||
"tempfile",
|
||||
"textwrap",
|
||||
"textwrap 0.16.0",
|
||||
"upon",
|
||||
"uuid",
|
||||
"walkdir 2.3.3",
|
||||
|
@ -443,6 +495,12 @@ dependencies = [
|
|||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.2"
|
||||
|
@ -529,18 +587,63 @@ dependencies = [
|
|||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "globset"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d"
|
||||
dependencies = [
|
||||
"aho-corasick 1.0.3",
|
||||
"bstr",
|
||||
"fnv",
|
||||
"log",
|
||||
"regex 1.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "globwalk"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"ignore",
|
||||
"walkdir 2.3.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.2"
|
||||
|
@ -602,6 +705,23 @@ dependencies = [
|
|||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ignore"
|
||||
version = "0.4.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492"
|
||||
dependencies = [
|
||||
"globset",
|
||||
"lazy_static 1.4.0",
|
||||
"log",
|
||||
"memchr",
|
||||
"regex 1.9.3",
|
||||
"same-file 1.0.6",
|
||||
"thread_local 1.1.7",
|
||||
"walkdir 2.3.3",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indenter"
|
||||
version = "0.3.3"
|
||||
|
@ -615,7 +735,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"autocfg 1.1.0",
|
||||
"hashbrown",
|
||||
"hashbrown 0.12.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -646,7 +776,7 @@ version = "1.0.11"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"hermit-abi 0.3.2",
|
||||
"libc",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
@ -657,11 +787,20 @@ version = "0.4.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"hermit-abi 0.3.2",
|
||||
"rustix 0.38.8",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.9"
|
||||
|
@ -862,7 +1001,7 @@ version = "1.16.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"hermit-abi 0.3.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -970,7 +1109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"indexmap",
|
||||
"indexmap 1.9.3",
|
||||
"line-wrap",
|
||||
"quick-xml",
|
||||
"serde",
|
||||
|
@ -1214,7 +1353,7 @@ dependencies = [
|
|||
"aho-corasick 0.6.10",
|
||||
"memchr",
|
||||
"regex-syntax 0.5.6",
|
||||
"thread_local",
|
||||
"thread_local 0.3.6",
|
||||
"utf8-ranges",
|
||||
]
|
||||
|
||||
|
@ -1262,6 +1401,77 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca136c6f6d53a2de7264bb392ea7c1f83357e00d131a24275b1661ea1c23c3af"
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "074e2507aedea43bdeb742cb55fc339a0704625050c9532a226c7ddbd1a05f62"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap 2.34.0",
|
||||
"globwalk",
|
||||
"itertools",
|
||||
"once_cell",
|
||||
"quote 1.0.32",
|
||||
"regex 1.9.3",
|
||||
"rust-i18n-extract",
|
||||
"rust-i18n-macro",
|
||||
"rust-i18n-support",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-extract"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e89ac25fb50c8d0893ee6436056fb4a0cc6f6e1df99239d7c104421d007d445e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ignore",
|
||||
"proc-macro2 1.0.66",
|
||||
"quote 1.0.32",
|
||||
"regex 1.9.3",
|
||||
"rust-i18n-support",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-macro"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e09ef5c1e310112eea3c19c4e18e3e62968b002eb535ff5b242ca1200742f996"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"once_cell",
|
||||
"proc-macro2 1.0.66",
|
||||
"quote 1.0.32",
|
||||
"rust-i18n-support",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-support"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14eb094cd0072c5f09f333eea36fcd8c64961f9eb61dbd09e82eff51c58e8414"
|
||||
dependencies = [
|
||||
"globwalk",
|
||||
"once_cell",
|
||||
"proc-macro2 1.0.66",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-serialize"
|
||||
version = "0.3.24"
|
||||
|
@ -1363,6 +1573,27 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.8.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
|
||||
dependencies = [
|
||||
"indexmap 1.9.3",
|
||||
"ryu",
|
||||
"serde",
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell-words"
|
||||
version = "1.1.0"
|
||||
|
@ -1401,6 +1632,12 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
|
@ -1418,6 +1655,17 @@ dependencies = [
|
|||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.66",
|
||||
"quote 1.0.32",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.28"
|
||||
|
@ -1483,6 +1731,15 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.16.0"
|
||||
|
@ -1523,6 +1780,16 @@ dependencies = [
|
|||
"lazy_static 1.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.25"
|
||||
|
@ -1553,6 +1820,40 @@ dependencies = [
|
|||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.19.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
|
||||
dependencies = [
|
||||
"indexmap 2.0.0",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typed-arena"
|
||||
version = "2.0.2"
|
||||
|
@ -1642,6 +1943,12 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
|
@ -1913,6 +2220,15 @@ version = "0.48.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.5.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xdg"
|
||||
version = "2.5.2"
|
||||
|
|
|
@ -46,6 +46,7 @@ nightly = ["punkt", "hyphenation"]
|
|||
crowbook-intl = "0.2"
|
||||
|
||||
[dependencies]
|
||||
rust-i18n = "2"
|
||||
html-escape = "0.2"
|
||||
mime_guess = "2"
|
||||
comrak = "0.18"
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
msg:
|
||||
autograph: "Enter autograph:"
|
||||
default_book: |
|
||||
"author: Your name"
|
||||
"title: Your title"
|
||||
"lang: en"
|
||||
|
||||
"## Output formats"
|
||||
|
||||
"# Uncomment and fill to generate files"
|
||||
"# output.html: some_file.html"
|
||||
"# output.epub: some_file.epub"
|
||||
"# output.pdf: some_file.pdf"
|
||||
|
||||
"# Or uncomment the following to generate PDF, HTML and EPUB files based on this file's name"
|
||||
"# output: [pdf, epub, html]"
|
||||
|
||||
"# Uncomment and fill to set cover image (for EPUB)"
|
||||
"# cover: some_cover.png"
|
||||
chapter_list: "\n## List of chapters\n"
|
||||
created: "Created %{file}, now you'll have to complete it!"
|
||||
cmd:
|
||||
about: Render a Markdown book in EPUB, PDF or HTML.
|
||||
single: Use a single Markdown file instead of a book configuration file
|
||||
emoji: Force emoji usage even if it might not work on your system
|
||||
verbose: Print warnings in parsing/rendering
|
||||
quiet: Don't print info/error messages
|
||||
create: Create a new book with existing Markdown files
|
||||
autograph: Prompts for an autograph for this book
|
||||
output: Specify output file
|
||||
lang: Set the runtime language used by Crowbook
|
||||
to: Generate specific format
|
||||
set: Set a list of book options
|
||||
no_fancy: Disably fancy UI
|
||||
list_options: List all possible options
|
||||
list_options_md: List all possible options, formatted in Markdown
|
||||
template: Prints the default content of a template
|
||||
book: File containing the book configuration file, or a Markdown file when called with --single
|
||||
stats: Print some project statistics
|
||||
clap:
|
||||
template: |
|
||||
|
||||
{bin} {version} by {author}
|
||||
{about}
|
||||
|
||||
USAGE:
|
||||
{usage}
|
||||
|
||||
OPTIONS:
|
||||
{options}
|
||||
|
||||
ARGS:
|
||||
{positionals}
|
||||
|
||||
error:
|
||||
invalid_template: "%{template} is not a valid template name"
|
||||
no_file: |
|
||||
You must pass the name of a book configuration file.
|
||||
For more information try --help.
|
||||
autograph: could not read autograph from stdin
|
||||
occurred: "Crowbook exited successfully, but the following errors occurred:"
|
||||
warning: WARNING
|
||||
error: ERROR
|
||||
odd_number: |
|
||||
An odd number of arguments was passed to --set, but it takes
|
||||
a list of key value pairs.
|
||||
set_key: "Error in setting key %{key}: %{error}"
|
||||
create: "Could not create file %{file}: it already exists!"
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2016-2022Élisabeth HENRY.
|
||||
// Copyright (C) 2016-2023Élisabeth HENRY.
|
||||
//
|
||||
// This file is part of Crowbook.
|
||||
//
|
||||
|
@ -18,6 +18,7 @@
|
|||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use console::style;
|
||||
use crowbook::Book;
|
||||
use rust_i18n::t;
|
||||
|
||||
use std::env;
|
||||
use std::fs;
|
||||
|
@ -33,7 +34,7 @@ pub fn print_warning(msg: &str, emoji: bool) {
|
|||
if emoji {
|
||||
eprint!("{}", style(WARNING).yellow());
|
||||
}
|
||||
eprintln!("{} {}", style(lformat!("WARNING")).bold().yellow(), msg);
|
||||
eprintln!("{} {}", style(t!("error.warning")).bold().yellow(), msg);
|
||||
}
|
||||
|
||||
/// Prints an error
|
||||
|
@ -41,7 +42,7 @@ pub fn print_error(s: &str, emoji: bool) {
|
|||
if emoji {
|
||||
eprint!("{}", style(ERROR).red());
|
||||
}
|
||||
eprintln!("{} {}", style(lformat!("ERROR")).bold().red(), s);
|
||||
eprintln!("{} {}", style(t!("error.error")).bold().red(), s);
|
||||
}
|
||||
|
||||
/// Prints an error on stderr and exit the program
|
||||
|
@ -82,10 +83,7 @@ pub fn get_book_options(matches: &ArgMatches) -> Vec<(&str, &str)> {
|
|||
let v: Vec<_> = iter.collect();
|
||||
if v.len() % 2 != 0 {
|
||||
print_error_and_exit(
|
||||
&lformat!(
|
||||
"An odd number of arguments was passed to --set, but it takes \
|
||||
a list of key value pairs."
|
||||
),
|
||||
&t!("error.odd_number"),
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
@ -96,9 +94,6 @@ pub fn get_book_options(matches: &ArgMatches) -> Vec<(&str, &str)> {
|
|||
output.push((key.as_str(), value.as_str()));
|
||||
}
|
||||
}
|
||||
if matches.get_flag("proofread") {
|
||||
output.push(("proofread", "true"));
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
|
@ -113,7 +108,7 @@ pub fn set_book_options(book: &mut Book, matches: &ArgMatches) -> String {
|
|||
for (key, value) in options {
|
||||
let res = book.options.set(key, value);
|
||||
if let Err(err) = res {
|
||||
print_error_and_exit(&lformat!("Error in setting key {}: {}", key, err), false);
|
||||
print_error_and_exit(&t!("error.set_key", key = key, error = err), false);
|
||||
}
|
||||
output.push_str(&format!("{key}: {value}\n"));
|
||||
}
|
||||
|
@ -126,7 +121,7 @@ pub fn create_book(matches: &ArgMatches) -> ! {
|
|||
let mut f: Box<dyn Write> = if let Some(book) = matches.get_one::<String>("BOOK") {
|
||||
if fs::metadata(book).is_ok() {
|
||||
print_error_and_exit(
|
||||
&lformat!("Could not create file {}: it already exists!", book),
|
||||
&t!("error.create", file = book),
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
@ -142,29 +137,12 @@ pub fn create_book(matches: &ArgMatches) -> ! {
|
|||
f.write_all(s.as_bytes()).unwrap();
|
||||
} else {
|
||||
f.write_all(
|
||||
lformat!(
|
||||
"author: Your name
|
||||
title: Your title
|
||||
lang: en
|
||||
|
||||
## Output formats
|
||||
|
||||
# Uncomment and fill to generate files
|
||||
# output.html: some_file.html
|
||||
# output.epub: some_file.epub
|
||||
# output.pdf: some_file.pdf
|
||||
|
||||
# Or uncomment the following to generate PDF, HTML and EPUB files based on this file's name
|
||||
# output: [pdf, epub, html]
|
||||
|
||||
# Uncomment and fill to set cover image (for EPUB)
|
||||
# cover: some_cover.png\n"
|
||||
)
|
||||
t!("msg.default_book")
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
f.write_all(lformat!("\n## List of chapters\n").as_bytes())
|
||||
f.write_all(t!("msg.chapter_list").as_bytes())
|
||||
.unwrap();
|
||||
for file in values {
|
||||
f.write_all(format!("+ {file}\n").as_bytes()).unwrap();
|
||||
|
@ -172,7 +150,7 @@ lang: en
|
|||
if let Some(s) = matches.get_one::<String>("BOOK") {
|
||||
println!(
|
||||
"{}",
|
||||
lformat!("Created {}, now you'll have to complete it!", s)
|
||||
t!("msg.created", file = s)
|
||||
);
|
||||
}
|
||||
exit(0);
|
||||
|
@ -188,37 +166,24 @@ pub fn create_matches() -> ArgMatches {
|
|||
// in its own function for testing purpose
|
||||
fn app() -> clap::Command {
|
||||
lazy_static! {
|
||||
static ref ABOUT: String = lformat!("Render a Markdown book in EPUB, PDF or HTML.");
|
||||
static ref SINGLE: String = lformat!("Use a single Markdown file instead of a book configuration file");
|
||||
static ref EMOJI: String = lformat!("Force emoji usage even if it might not work on your system");
|
||||
static ref VERBOSE: String = lformat!("Print warnings in parsing/rendering");
|
||||
static ref QUIET: String = lformat!("Don't print info/error messages");
|
||||
static ref PROOFREAD: String = lformat!("Enable proofreading");
|
||||
static ref CREATE: String = lformat!("Create a new book with existing Markdown files");
|
||||
static ref AUTOGRAPH: String = lformat!("Prompts for an autograph for this book");
|
||||
static ref OUTPUT: String = lformat!("Specify output file");
|
||||
static ref LANG: String = lformat!("Set the runtime language used by Crowbook");
|
||||
static ref TO: String = lformat!("Generate specific format");
|
||||
static ref SET: String = lformat!("Set a list of book options");
|
||||
static ref NO_FANCY: String = lformat!("Disably fancy UI");
|
||||
static ref LIST_OPTIONS: String = lformat!("List all possible options");
|
||||
static ref LIST_OPTIONS_MD: String = lformat!("List all possible options, formatted in Markdown");
|
||||
static ref PRINT_TEMPLATE: String = lformat!("Prints the default content of a template");
|
||||
static ref BOOK: String = lformat!("File containing the book configuration file, or a Markdown file when called with --single");
|
||||
static ref STATS: String = lformat!("Print some project statistics");
|
||||
static ref TEMPLATE: String = lformat!("\
|
||||
{{bin}} {{version}} by {{author}}
|
||||
{{about}}
|
||||
|
||||
USAGE:
|
||||
{{usage}}
|
||||
|
||||
OPTIONS:
|
||||
{{options}}
|
||||
|
||||
ARGS:
|
||||
{{positionals}}
|
||||
");
|
||||
static ref ABOUT: String = t!("cmd.about");
|
||||
static ref SINGLE: String = t!("cmd.single");
|
||||
static ref EMOJI: String = t!("cmd.emoji");
|
||||
static ref VERBOSE: String = t!("cmd.verbose");
|
||||
static ref QUIET: String = t!("cmd.quiet");
|
||||
static ref CREATE: String = t!("cmd.create");
|
||||
static ref AUTOGRAPH: String = t!("cmd.autograph");
|
||||
static ref OUTPUT: String = t!("cmd.output");
|
||||
static ref LANG: String = t!("cmd.lang");
|
||||
static ref TO: String = t!("cmd.to");
|
||||
static ref SET: String = t!("cmd.set");
|
||||
static ref NO_FANCY: String = t!("cmd.no_fancy");
|
||||
static ref LIST_OPTIONS: String = t!("cmd.list_options");
|
||||
static ref LIST_OPTIONS_MD: String = t!("cmd.list_options_md");
|
||||
static ref PRINT_TEMPLATE: String = t!("cmd.template");
|
||||
static ref BOOK: String = t!("cmd.book");
|
||||
static ref STATS: String = t!("cmd.stats");
|
||||
static ref TEMPLATE: String = t!("clap.template");
|
||||
}
|
||||
|
||||
let app = Command::new("crowbook")
|
||||
|
@ -269,13 +234,6 @@ ARGS:
|
|||
.help(QUIET.as_str())
|
||||
.conflicts_with("verbose"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("proofread")
|
||||
.short('p')
|
||||
.long("poofread")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help(PROOFREAD.as_str()),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("files")
|
||||
.short('c')
|
||||
|
@ -305,10 +263,6 @@ ARGS:
|
|||
"tex",
|
||||
"odt",
|
||||
"html.dir",
|
||||
"proofread.html",
|
||||
"proofread.html.dir",
|
||||
"proofread.pdf",
|
||||
"proofread.tex",
|
||||
])
|
||||
.help(TO.as_str()),
|
||||
)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
extern crate crowbook;
|
||||
extern crate crowbook_intl_runtime;
|
||||
extern crate yaml_rust;
|
||||
|
||||
#[macro_use]
|
||||
mod localize_macros;
|
||||
#[cfg(feature = "binary")]
|
||||
|
@ -13,6 +9,9 @@ mod real_main;
|
|||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
rust_i18n::i18n!("lang/bin", fallback="en");
|
||||
|
||||
|
||||
#[cfg(feature = "binary")]
|
||||
fn main() {
|
||||
crate::real_main::real_main();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2016-2022 Élisabeth HENRY.
|
||||
// Copyright (C) 2016-2023 Élisabeth HENRY.
|
||||
//
|
||||
// This file is part of Crowbook.
|
||||
//
|
||||
|
@ -17,11 +17,10 @@
|
|||
|
||||
use crate::helpers::*;
|
||||
|
||||
use clap::ArgMatches;
|
||||
|
||||
use crowbook::Stats;
|
||||
use crowbook::{Book, BookOptions, Result};
|
||||
use crowbook_intl_runtime::set_lang;
|
||||
|
||||
use clap::ArgMatches;
|
||||
use simplelog::{ConfigBuilder, LevelFilter, SimpleLogger, TermLogger, WriteLogger};
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
|
@ -29,6 +28,8 @@ use std::io;
|
|||
use std::io::Read;
|
||||
use std::process::exit;
|
||||
use yaml_rust::Yaml;
|
||||
use rust_i18n::t;
|
||||
|
||||
|
||||
/// Render a book to specific format
|
||||
fn render_format(book: &mut Book, emoji: bool, matches: &ArgMatches, format: &str) {
|
||||
|
@ -66,9 +67,9 @@ pub fn try_main() -> Result<()> {
|
|||
});
|
||||
if let Some(val) = lang {
|
||||
if val.starts_with("fr") {
|
||||
set_lang("fr");
|
||||
rust_i18n::set_locale("fr");
|
||||
} else {
|
||||
set_lang("en");
|
||||
rust_i18n::set_locale("en");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ pub fn try_main() -> Result<()> {
|
|||
exit(0);
|
||||
}
|
||||
Err(_) => print_error_and_exit(
|
||||
&lformat!("{} is not a valid template name.", template),
|
||||
&t!("error.invalid_template", template = template),
|
||||
emoji,
|
||||
),
|
||||
}
|
||||
|
@ -122,10 +123,7 @@ pub fn try_main() -> Result<()> {
|
|||
let book = matches.get_one::<String>("BOOK");
|
||||
if book.is_none() {
|
||||
print_error_and_exit(
|
||||
&lformat!(
|
||||
"You must pass the file of a book configuration \
|
||||
file.\nFor more information try --help."
|
||||
),
|
||||
&t!("error.no_file"),
|
||||
emoji,
|
||||
);
|
||||
}
|
||||
|
@ -173,7 +171,7 @@ pub fn try_main() -> Result<()> {
|
|||
{
|
||||
let mut book = Book::new();
|
||||
if matches.get_flag("autograph") {
|
||||
println!("{}", &lformat!("Enter autograph: "));
|
||||
println!("{}", &t!("msg.autograph"));
|
||||
let mut autograph = String::new();
|
||||
match io::stdin().read_to_string(&mut autograph) {
|
||||
Ok(_) => {
|
||||
|
@ -184,7 +182,7 @@ pub fn try_main() -> Result<()> {
|
|||
)
|
||||
.unwrap();
|
||||
}
|
||||
Err(_) => print_error(&lformat!("could not read autograph from stdin"), emoji),
|
||||
Err(_) => print_error(&t!("error.autograph") , emoji),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +234,7 @@ pub fn try_main() -> Result<()> {
|
|||
file.read_to_string(&mut errors).unwrap();
|
||||
if !errors.is_empty() {
|
||||
print_warning(
|
||||
&lformat!("Crowbook exited successfully, but the following errors occurred:"),
|
||||
&t!("error.occurred"),
|
||||
emoji,
|
||||
);
|
||||
// Non-efficient dedup algorithm but we need to keep the order
|
||||
|
|
Loading…
Reference in New Issue