19 Commits

Author SHA1 Message Date
c33428f3e1 builder rewrite wip 2025-11-12 22:49:59 +01:00
fc98b48601 setting output and input is now global 2025-11-11 13:03:26 +01:00
bf30e8eeb6 updated readme 2025-11-10 17:58:20 +01:00
fa9f282194 updated some things like help text, fixing custom docs dir 2025-11-10 17:54:09 +01:00
64400c07c7 updated .gitignore with asciidocs directory 2025-11-10 17:30:47 +01:00
b3d6d21ea5 added asciidocs directory to the resources for testing 2025-11-10 17:30:15 +01:00
a0bdc34792 reverted test resource 2025-11-10 16:59:58 +01:00
659bb5da63 wip docs dir 2025-11-10 16:50:04 +01:00
24e1ade129 docs dir wip 2025-11-10 16:50:04 +01:00
88dc0e47b1 added config file for some options 2025-11-10 16:50:04 +01:00
0ae02c8950 Merge pull request #9 from quirinecker/fix/8-progress-jumps
Fix/8 progress jumps
2025-11-10 14:28:49 +01:00
e053f51bf3 removed old useless code for not building the reveal js things 2025-11-10 14:24:42 +01:00
f3bfd8c114 filtering out paths before building process 2025-11-10 14:23:15 +01:00
2ed789aa46 Merge pull request #7 from quirinecker/feature/2-when-ascidoctor-reveal-js-is-missing-it-should-say-so-instead-of-saying-asciidoctor-itself-is-missing
When ascidoctor reveal js is missing it should say so instead of saying asciidoctor itself is missing

Closes #2
2025-11-10 13:49:15 +01:00
131bf15240 now displaying missing binary instead of allways asciidoctro. Tested 2025-11-10 13:43:07 +01:00
fd1fe0d896 printing missing binary in the case something is missing. testing later 2025-11-09 22:11:19 +01:00
5996db8d80 Merge pull request #6 from quirinecker/4-make-serving-link-a-clickable-link
Serving link is now clickable
2025-11-09 22:05:32 +01:00
2df54930bb making it allways run on pull requests for now 2025-11-09 22:03:57 +01:00
f7a1f84730 removed colored library, using nu-ansi-term now 2025-11-09 21:54:22 +01:00
26 changed files with 763 additions and 261 deletions

View File

@@ -8,9 +8,6 @@ on:
- "./Cargo.toml"
pull_request:
branches: ["main", "develop"]
paths:
- "./src/**"
- "./Cargo.toml"
env:
CARGO_TERM_COLOR: always

2
.gitignore vendored
View File

@@ -1,6 +1,6 @@
/target
dist
/docs
res/test/docs/slides/revealjs
res/test/asciidocs/slides/revealjs
res/test/result
result

471
Cargo.lock generated
View File

@@ -98,6 +98,12 @@ version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800"
[[package]]
name = "arraydeque"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
[[package]]
name = "arrayref"
version = "0.3.6"
@@ -117,7 +123,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5"
dependencies = [
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -304,13 +310,13 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"
[[package]]
name = "async-trait"
version = "0.1.66"
version = "0.1.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc"
checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.110",
]
[[package]]
@@ -394,6 +400,15 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
dependencies = [
"serde_core",
]
[[package]]
name = "blake3"
version = "0.3.8"
@@ -542,7 +557,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
dependencies = [
"atty",
"bitflags",
"bitflags 1.3.2",
"clap_derive 3.2.18",
"clap_lex 0.2.4",
"indexmap",
@@ -558,7 +573,7 @@ version = "4.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"clap_derive 4.1.8",
"clap_lex 0.3.2",
"is-terminal",
@@ -586,7 +601,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -599,7 +614,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -630,17 +645,6 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "colored"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
dependencies = [
"atty",
"lazy_static",
"winapi 0.3.9",
]
[[package]]
name = "concurrent-queue"
version = "2.1.0"
@@ -650,6 +654,46 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "config"
version = "0.15.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180e549344080374f9b32ed41bf3b6b57885ff6a289367b3dbc10eea8acc1918"
dependencies = [
"async-trait",
"convert_case",
"json5",
"pathdiff",
"ron",
"rust-ini",
"serde-untagged",
"serde_core",
"serde_json",
"toml",
"winnow",
"yaml-rust2",
]
[[package]]
name = "const-random"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
dependencies = [
"const-random-macro",
]
[[package]]
name = "const-random-macro"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
dependencies = [
"getrandom 0.2.8",
"once_cell",
"tiny-keccak",
]
[[package]]
name = "const_fn"
version = "0.4.9"
@@ -662,6 +706,15 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]]
name = "convert_case"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "cookie"
version = "0.14.4"
@@ -738,6 +791,12 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "crunchy"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-common"
version = "0.1.6"
@@ -775,7 +834,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
dependencies = [
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -811,7 +870,7 @@ dependencies = [
"proc-macro2",
"quote",
"scratch",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -828,7 +887,7 @@ checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -857,6 +916,15 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
[[package]]
name = "dlv-list"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
dependencies = [
"const-random",
]
[[package]]
name = "docki"
version = "1.2.3"
@@ -864,13 +932,15 @@ dependencies = [
"bytes",
"clap 4.1.8",
"clap_complete",
"colored",
"config",
"futures",
"home",
"live-server",
"notify 5.1.0",
"nu-ansi-term",
"regex",
"reqwest",
"serde",
"text_io",
"tokio",
"zip-extract",
@@ -878,9 +948,9 @@ dependencies = [
[[package]]
name = "encoding_rs"
version = "0.8.32"
version = "0.8.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394"
checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
dependencies = [
"cfg-if 1.0.0",
]
@@ -907,6 +977,17 @@ dependencies = [
"serde",
]
[[package]]
name = "erased-serde"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89e8918065695684b2b0702da20382d5ae6065cf3327bc2d6436bd49a71ce9f3"
dependencies = [
"serde",
"serde_core",
"typeid",
]
[[package]]
name = "errno"
version = "0.2.8"
@@ -987,6 +1068,12 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "foreign-types"
version = "0.3.2"
@@ -1017,7 +1104,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"fsevent-sys 2.0.1",
]
@@ -1045,7 +1132,7 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"fuchsia-zircon-sys",
]
@@ -1126,7 +1213,7 @@ checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -1238,6 +1325,30 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"foldhash",
]
[[package]]
name = "hashlink"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
dependencies = [
"hashbrown 0.15.5",
]
[[package]]
name = "heck"
version = "0.4.1"
@@ -1468,7 +1579,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
dependencies = [
"autocfg",
"hashbrown",
"hashbrown 0.12.3",
]
[[package]]
@@ -1483,7 +1594,7 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"inotify-sys",
"libc",
]
@@ -1494,7 +1605,7 @@ version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"inotify-sys",
"libc",
]
@@ -1587,6 +1698,17 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "json5"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1"
dependencies = [
"pest",
"pest_derive",
"serde",
]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
@@ -1613,7 +1735,7 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"libc",
]
@@ -1841,7 +1963,7 @@ version = "4.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"filetime",
"fsevent",
"fsevent-sys 2.0.1",
@@ -1859,7 +1981,7 @@ version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58ea850aa68a06e48fdb069c0ec44d0d64c8dbffa49bf3b6f7f0a901fdea1ba9"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"crossbeam-channel",
"filetime",
"fsevent-sys 4.1.0",
@@ -1872,6 +1994,15 @@ dependencies = [
"windows-sys 0.42.0",
]
[[package]]
name = "nu-ansi-term"
version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "num-integer"
version = "0.1.45"
@@ -1919,7 +2050,7 @@ version = "0.10.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"cfg-if 1.0.0",
"foreign-types",
"libc",
@@ -1936,7 +2067,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -1958,6 +2089,16 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "ordered-multimap"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79"
dependencies = [
"dlv-list",
"hashbrown 0.14.5",
]
[[package]]
name = "os_str_bytes"
version = "6.4.1"
@@ -2004,6 +2145,12 @@ dependencies = [
"subtle",
]
[[package]]
name = "pathdiff"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
[[package]]
name = "pbkdf2"
version = "0.11.0"
@@ -2022,6 +2169,49 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "pest"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4"
dependencies = [
"memchr",
"ucd-trie",
]
[[package]]
name = "pest_derive"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de"
dependencies = [
"pest",
"pest_generator",
]
[[package]]
name = "pest_generator"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843"
dependencies = [
"pest",
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.110",
]
[[package]]
name = "pest_meta"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a"
dependencies = [
"pest",
"sha2 0.10.6",
]
[[package]]
name = "pin-project"
version = "1.0.12"
@@ -2039,7 +2229,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -2073,7 +2263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e1f879b2998099c2d69ab9605d145d5b661195627eccc680002c4918a7fb6fa"
dependencies = [
"autocfg",
"bitflags",
"bitflags 1.3.2",
"cfg-if 1.0.0",
"concurrent-queue",
"libc",
@@ -2108,7 +2298,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
"version_check",
]
@@ -2131,18 +2321,18 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]]
name = "proc-macro2"
version = "1.0.52"
version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224"
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.24"
version = "1.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50686e0021c4136d1d453b2dfe059902278681512a34d4248435dc34b6b5c8ec"
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
dependencies = [
"proc-macro2",
]
@@ -2224,7 +2414,7 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags",
"bitflags 1.3.2",
]
[[package]]
@@ -2281,12 +2471,34 @@ dependencies = [
"winreg",
]
[[package]]
name = "ron"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
dependencies = [
"base64 0.21.0",
"bitflags 2.10.0",
"serde",
"serde_derive",
]
[[package]]
name = "route-recognizer"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56770675ebc04927ded3e60633437841581c285dc6236109ea25fbf3beb7b59e"
[[package]]
name = "rust-ini"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "796e8d2b6696392a43bea58116b667fb4c29727dc5abd27d6acf338bb4f688c7"
dependencies = [
"cfg-if 1.0.0",
"ordered-multimap",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
@@ -2302,7 +2514,7 @@ version = "0.36.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"errno",
"io-lifetimes",
"libc",
@@ -2352,7 +2564,7 @@ version = "2.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"core-foundation",
"core-foundation-sys",
"libc",
@@ -2386,22 +2598,44 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.155"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
name = "serde-untagged"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058"
dependencies = [
"erased-serde 0.4.9",
"serde",
"serde_core",
"typeid",
]
[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.155"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.110",
]
[[package]]
@@ -2415,13 +2649,15 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.94"
version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea"
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
"serde_core",
]
[[package]]
@@ -2435,6 +2671,15 @@ dependencies = [
"thiserror",
]
[[package]]
name = "serde_spanned"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392"
dependencies = [
"serde_core",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -2596,7 +2841,7 @@ dependencies = [
"quote",
"serde",
"serde_derive",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -2612,7 +2857,7 @@ dependencies = [
"serde_derive",
"serde_json",
"sha1 0.6.1",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -2653,6 +2898,17 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tempfile"
version = "3.4.0"
@@ -2704,7 +2960,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -2810,7 +3066,16 @@ dependencies = [
"proc-macro2",
"quote",
"standback",
"syn",
"syn 1.0.109",
]
[[package]]
name = "tiny-keccak"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
dependencies = [
"crunchy",
]
[[package]]
@@ -2856,7 +3121,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
@@ -2883,6 +3148,37 @@ dependencies = [
"tracing",
]
[[package]]
name = "toml"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8"
dependencies = [
"serde_core",
"serde_spanned",
"toml_datetime",
"toml_parser",
"winnow",
]
[[package]]
name = "toml_datetime"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533"
dependencies = [
"serde_core",
]
[[package]]
name = "toml_parser"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e"
dependencies = [
"winnow",
]
[[package]]
name = "tower-service"
version = "0.3.2"
@@ -2935,12 +3231,24 @@ dependencies = [
"utf-8",
]
[[package]]
name = "typeid"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c"
[[package]]
name = "typenum"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "ucd-trie"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
[[package]]
name = "unicase"
version = "2.6.0"
@@ -2971,6 +3279,12 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-segmentation"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "unicode-width"
version = "0.1.10"
@@ -3021,7 +3335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55"
dependencies = [
"ctor",
"erased-serde",
"erased-serde 0.3.25",
"serde",
"serde_fmt",
"sval",
@@ -3108,7 +3422,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
"wasm-bindgen-shared",
]
@@ -3142,7 +3456,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -3206,6 +3520,12 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.42.0"
@@ -3230,6 +3550,15 @@ dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[[package]]
name = "windows-targets"
version = "0.42.1"
@@ -3287,6 +3616,15 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
[[package]]
name = "winnow"
version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf"
dependencies = [
"memchr",
]
[[package]]
name = "winreg"
version = "0.10.1"
@@ -3306,6 +3644,17 @@ dependencies = [
"winapi-build",
]
[[package]]
name = "yaml-rust2"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2462ea039c445496d8793d052e13787f2b90e750b833afee748e601c17621ed9"
dependencies = [
"arraydeque",
"encoding_rs",
"hashlink",
]
[[package]]
name = "zip"
version = "0.6.4"

View File

@@ -12,7 +12,6 @@ exclude = [".gitlab", ".github"]
[dependencies]
bytes = "1.4.0"
clap = { version = "4.1.8", features = ["derive"] }
colored = "2.0.0"
futures = "0.3.26"
home = "0.5.4"
live-server = "0.6.0"
@@ -23,3 +22,6 @@ text_io = "0.1.12"
tokio = { version = "1.26.0", features = ["full"] }
zip-extract = "0.1.1"
clap_complete = "4.1.4"
nu-ansi-term = "0.50.3"
config = { version = "0.15.18", features = ["toml"] }
serde = "1.0.228"

View File

@@ -112,6 +112,10 @@ home.packages = with pkgs; [
]
```
## Configuration
You can configure some of the cli arguments with a config file. It is always located relatively to the current directory under `./docki.config.toml`. Available options and their defaults can be found in the [config.rs](src/app/config/config.rs) file. CLI arguments with the same names as in the config usually have also the same default values.
## Development
### Running it

View File

@@ -0,0 +1,16 @@
= My Project
:toc:
:toc-title:
:toclevels: 2
== Introduction
This is my project.
== Slides
* link:slides/index.html[Presentation]
== License
This project is licensed under the MIT License - see the link:LICENSE[LICENSE] file for details.

View File

@@ -0,0 +1,19 @@
# Slides
## Slide 1
* First
* Second
* Third
## Slide 2
* First
* Second
* Third
### Slide 3
* First
* Second
* Third

View File

@@ -0,0 +1,3 @@
docs_dir = "./docs"
port = 6969
offline_reveal = false

View File

View File

@@ -0,0 +1,16 @@
= My Project
:toc:
:toc-title:
:toclevels: 2
== Introduction
This is my project.
== Slides
* link:slides/index.html[Presentation]
== License
This project is licensed under the MIT License - see the link:LICENSE[LICENSE] file for details.

View File

@@ -1,11 +1,19 @@
= My cool presentation
:author: John Doe
:email: john@doe.com
# Slides
== First slide
## Slide 1
Content
* First
* Second
* Third
== Second slide
## Slide 2
Content
* First
* Second
* Third
### Slide 3
* First
* Second
* Third

View File

@@ -12,9 +12,13 @@ fn exec_command(command: &mut process::Command) -> Result<(), String> {
}
} else {
println!("{}", result.unwrap_err());
return Err(
"asciidoctor not installed. For more information run docki health!".to_string(),
);
let binary_name = command.get_program().to_str().unwrap_or("Something is");
return Err(format!(
"{} not installed. For more information run docki health!",
binary_name
));
}
}
@@ -31,11 +35,11 @@ fn asciidoctor_docs(in_path: &str, out_path: &str) -> process::Command {
fn asciidoctor_slides(in_path: &str, out_path: &str, offline_reveal: bool) -> process::Command {
let mut command = process::Command::new(format!("asciidoctor-revealjs"));
let out_dir = parent_path(out_path);
let revealjs_path = if offline_reveal {
path_between(out_dir.to_string(), "./dist/slides/revealjs".to_string())
} else {
"https://cdn.jsdelivr.net/npm/reveal.js@5.2.1".to_string()
};
let revealjs_path = if offline_reveal {
path_between(out_dir.to_string(), "./dist/slides/revealjs".to_string())
} else {
"https://cdn.jsdelivr.net/npm/reveal.js@5.2.1".to_string()
};
command
.arg(format!("{in_path}"))

View File

@@ -1,54 +1 @@
use std::fs;
use self::asciidoctor::{build_doc, build_slide};
use super::fs_util;
pub mod asciidoctor;
pub fn docki_build(in_path: &str, offline_reveal: bool) -> DockiBuildResult {
let out_path = in_path.replace("/docs/", "/dist/");
let convert_out_path = out_path.replace(".adoc", ".html");
if in_path.starts_with("./docs/slides/") && in_path.ends_with(".adoc") {
if let Err(err) = build_slide(&in_path, &convert_out_path, offline_reveal) {
return DockiBuildResult::Err(err);
}
DockiBuildResult::Slide(convert_out_path)
} else if in_path.ends_with(".adoc") {
if let Err(err) = build_doc(&in_path, &convert_out_path) {
return DockiBuildResult::Err(err);
}
DockiBuildResult::Doc(convert_out_path)
} else {
if in_path.starts_with("./docs/slides/revealjs") && !offline_reveal {
return DockiBuildResult::Silent;
}
if let Err(err) = copy(&in_path, &out_path) {
return DockiBuildResult::Err(err);
}
DockiBuildResult::Copy(out_path)
}
}
fn copy(in_path: &str, out_path: &str) -> Result<(), String> {
fs_util::create_parent_dir_recursive(out_path);
if let Err(err) = fs::copy(in_path, out_path) {
return Err(err.to_string());
}
Ok(())
}
pub enum DockiBuildResult {
Slide(String),
Doc(String),
Copy(String),
Err(String),
Silent,
}

View File

@@ -1,6 +1,10 @@
use crate::app::config::config::Config;
use super::executions::build_execution::BuildExecution;
pub async fn build(offline_reveal: bool) -> () {
let mut build_execution = BuildExecution::new();
build_execution.execute(offline_reveal).await.expect("build failed")
pub async fn build(config: &Config) -> () {
let mut build_execution = BuildExecution::new(config);
build_execution.prepare().await.expect("could not prepare for build");
build_execution.build_dir().expect("build failed")
}

View File

@@ -3,7 +3,7 @@ use std::io;
use clap::CommandFactory;
use clap_complete::{generate, shells::{Bash, Fish, Zsh}};
use crate::app::args::structure::{Args, ShellArg};
use crate::app::config::arguments::{Args, ShellArg};
pub fn completions(shell: ShellArg) {
let mut command = Args::command();

View File

@@ -1,52 +1,41 @@
use std::{
io::Cursor,
path::PathBuf
fs, io::Cursor, path::PathBuf
};
use crate::app::{
build::{docki_build, DockiBuildResult},
fs_util::{self, create_dir_recursive}, log::display_status,
build::{asciidoctor::build_slide, asciidoctor::build_doc}, config::config::Config, fs_util::{self, create_dir_recursive}, log::display_status
};
pub struct BuildExecution {
pub struct BuildExecution<'a> {
progress: usize,
goal: usize,
config: &'a Config
}
impl BuildExecution {
pub fn new() -> Self {
return BuildExecution {
impl <'a> BuildExecution <'a> {
pub fn new(config: &'a Config) -> Self {
return Self {
progress: 0,
goal: 0,
config: config
};
}
pub async fn execute(&mut self, offline_reveal: bool) -> Result<(), String> {
let path = "./docs/".to_string();
if !fs_util::directory_exists(&path) {
pub async fn prepare(&self) -> Result<(), String> {
if !fs_util::directory_exists(&self.config.input_dir) {
return Err(
"docs directory does not exist it. Create it or use the template".to_string(),
);
}
if let Err(error) = Self::prepare(offline_reveal).await {
return Err(error);
}
return self.build_dir(&path, offline_reveal);
}
async fn prepare(offline_reveal: bool) -> Result<(), String> {
if !offline_reveal {
if !self.config.offline_reveal {
return Ok(())
}
let reveal_version = "5.2.1";
let target = format!("https://github.com/hakimel/reveal.js/archive/{reveal_version}.zip");
create_dir_recursive("./docs/slides");
create_dir_recursive(format!("{}/slides", self.config.input_dir).as_str());
reqwest::get(target.clone()).await.unwrap();
let Ok(response) = reqwest::get(target).await else {
@@ -57,7 +46,7 @@ impl BuildExecution {
return Err("could not extract bytes".to_string())
};
let out = PathBuf::from("./docs/slides/revealjs");
let out = PathBuf::from(format!("{}/slides/revealjs", self.config.input_dir));
if zip_extract::extract(Cursor::new(bytes), &out, true).is_err() {
return Err("could not write extracted archive to disk".to_string());
@@ -66,36 +55,83 @@ impl BuildExecution {
return Ok(());
}
fn build_dir(&mut self, path: &str, offline_reveal: bool) -> Result<(), String> {
let result = fs_util::fetch_paths_recursive(&path);
pub fn build_dir(&mut self) -> Result<(), String> {
let result = fs_util::fetch_paths_recursive(&self.config.input_dir);
let Ok(paths) = result else {
return Err(result.unwrap_err())
};
let reveal_dir = format!("{}/slides/revealjs", self.config.input_dir);
let paths = paths.into_iter()
.filter(|path| self.config.offline_reveal || !path.starts_with(reveal_dir.as_str()))
.collect::<Vec<String>>();
self.goal = paths.len();
for (index, in_path) in paths.iter().enumerate() {
self.progress = index + 1;
self.goal = paths.len();
let result = docki_build(&in_path, offline_reveal);
let result = self.build_file(&in_path);
match result {
DockiBuildResult::Err(err) => {
self.display_building_status("Error", in_path, "");
self.display_building_status("Error", &in_path, "");
println!("{}", err)
},
DockiBuildResult::Copy(out_path) => self.display_building_status("Copy", &in_path, &out_path),
DockiBuildResult::Slide(out_path) => self.display_building_status("Slide", &in_path, &out_path),
DockiBuildResult::Doc(out_path) => self.display_building_status("Doc", &in_path, &out_path),
DockiBuildResult::Silent => ()
}
}
return Ok(());
}
pub fn build_file(&mut self, path: &str) -> DockiBuildResult {
let out_path = path.replace(&self.config.input_dir, "./dist");
let convert_out_path = out_path.replace(".adoc", ".html");
if path.starts_with(format!("{}/slides/", &self.config.input_dir).as_str()) && path.ends_with(".adoc") {
if let Err(err) = build_slide(&path, &convert_out_path, self.config.offline_reveal) {
return DockiBuildResult::Err(err);
}
DockiBuildResult::Slide(convert_out_path)
} else if path.ends_with(".adoc") {
if let Err(err) = build_doc(&path, &convert_out_path) {
return DockiBuildResult::Err(err);
}
DockiBuildResult::Doc(convert_out_path)
} else {
if let Err(err) = Self::copy(&path, &out_path) {
return DockiBuildResult::Err(err);
}
DockiBuildResult::Copy(out_path)
}
}
fn copy(in_path: &str, out_path: &str) -> Result<(), String> {
fs_util::create_parent_dir_recursive(out_path);
if let Err(err) = fs::copy(in_path, out_path) {
return Err(err.to_string());
}
Ok(())
}
fn display_building_status(&self, status_type: &str, in_path: &str, out_path: &str) -> () {
let progress_str = format!("{} / {}", self.progress, self.goal);
display_status(&progress_str, status_type, in_path, out_path);
}
}
pub enum DockiBuildResult {
Slide(String),
Doc(String),
Copy(String),
Err(String),
}

View File

@@ -1,5 +1,5 @@
use std::{process::Command, io::ErrorKind};
use colored::Colorize;
use nu_ansi_term::Color::{LightGray, LightGreen, LightRed};
use std::{io::ErrorKind, process::Command};
const INFO_ASCIIDOC: &str = "
Install the binary with your package manager!
@@ -37,7 +37,7 @@ fn check_reveal() -> () {
}
fn reveal_is_installed() -> bool {
return check_command("asciidoctor-revealjs")
return check_command("asciidoctor-revealjs");
}
fn check_asciidoc() -> () {
@@ -49,23 +49,21 @@ fn check_asciidoc() -> () {
}
fn asciidoc_is_installed() -> bool {
return check_command("asciidoctor")
return check_command("asciidoctor");
}
fn check_command(command: &str) -> bool {
return match Command::new(command)
.output() {
return match Command::new(command).output() {
Ok(_) => true,
Err(e) => ErrorKind::NotFound != e.kind()
}
Err(e) => ErrorKind::NotFound != e.kind(),
};
}
fn print_health_ok(name: &str) {
println!("- ✔️ {}", name.bright_green());
println!("- ✔️ {}", LightGreen.paint(name));
}
fn print_health_not_ok(name: &str, info: &str) {
println!("- ❗{}", name.bright_red());
println!("{}", info.bright_black())
println!("- ❗{}", LightRed.paint(name));
println!("{}", LightGray.paint(info))
}

View File

@@ -1,4 +1,4 @@
use colored::Colorize;
use nu_ansi_term::Color::Green;
use futures::StreamExt;
use live_server::listen;
use notify::{
@@ -7,77 +7,104 @@ use notify::{
};
use std::{env, path::Path};
use crate::app::{ watcher::watcher, build::{docki_build, DockiBuildResult}, commands::build::build, log::display_status};
use crate::app::{ commands::executions::build_execution::{self, BuildExecution, DockiBuildResult}, config::config::Config, log::display_status, watcher::watcher};
pub async fn serve(port: Option<u16>) {
build(false).await;
tokio::join!(watch_and_build(), start_server(port));
pub async fn serve(config: &Config) {
let build_execution = BuildExecution::new(config);
let mut server = Server::new(build_execution, config);
server.serve().await;
}
async fn watch_and_build() {
watch(Path::new("./docs"))
.await
.expect("something went wrong")
struct Server<'a> {
build_execution: BuildExecution<'a>,
config: &'a Config,
}
async fn start_server(port: Option<u16>) {
let unwrapped_port = port.unwrap_or(8080);
println!(
"\nServing at {}{} ",
"http://localhost:".bold(),
unwrapped_port.to_string().bold()
);
impl <'a> Server <'a> {
pub fn new(build_execution: BuildExecution<'a>, config: &'a Config) -> Self {
return Self {
build_execution: build_execution,
config: config
}
}
let Ok(()) = listen("localhost", port.unwrap_or(8080), "./dist").await else {
panic!("could not start server")
};
async fn serve(&mut self) {
self.build_execution.prepare().await.expect("could not prepare for build");
self.build_execution.build_dir().expect("build failed");
tokio::join!(self.start_server(), self.watch_and_build());
}
async fn start_server(&self) {
let link = &format!("http://localhost:{}", self.config.port);
let hyperlink = Green.paint(link).hyperlink(link);
println!(
"\nServing at {}",
hyperlink
);
let Ok(()) = listen("localhost", self.config.port, "./dist").await else {
panic!("could not start server")
};
}
async fn watch_and_build(&mut self) {
self.watch()
.await
.expect("something went wrong")
}
async fn watch(&mut self) -> notify::Result<()> {
let path = Path::new(&self.config.input_dir);
let (mut watcher, mut rx) = watcher()?;
watcher.watch(path.as_ref(), RecursiveMode::Recursive)?;
while let Some(res) = rx.next().await {
let event = res.expect("watching failed");
self.file_change(event)
}
Ok(())
}
fn file_change(&mut self, event: Event) {
match event.kind {
EventKind::Modify(ModifyKind::Data(_)) => self.build_file(event.paths),
_ => (),
}
}
fn build_file(&mut self, paths: Vec<std::path::PathBuf>) {
let invalid_path_message = "changed path is invalid";
let in_path = paths
.first()
.expect(invalid_path_message)
.strip_prefix(&current_dir())
.expect(invalid_path_message)
.to_str()
.expect(invalid_path_message);
let in_path = format!("./{}", in_path);
let result = self.build_execution.build_file(&in_path);
match result {
DockiBuildResult::Slide(out_path) => display_rebuilding_status("Slide", &in_path, &out_path),
DockiBuildResult::Doc(out_path) => display_rebuilding_status("Doc", &in_path, &out_path),
DockiBuildResult::Copy(out_path) => display_rebuilding_status("Copy", &in_path, &out_path),
DockiBuildResult::Err(err) => {
display_rebuilding_status("Error", &in_path, "");
println!("{}", err);
},
}
}
}
async fn watch(path: &Path) -> notify::Result<()> {
let (mut watcher, mut rx) = watcher()?;
watcher.watch(path.as_ref(), RecursiveMode::Recursive)?;
while let Some(res) = rx.next().await {
let event = res.expect("watching failed");
file_change(event)
}
Ok(())
}
fn file_change(event: Event) {
match event.kind {
EventKind::Modify(ModifyKind::Data(_)) => build_file(event.paths),
_ => (),
}
}
fn build_file(paths: Vec<std::path::PathBuf>) {
let invalid_path_message = "changed path is invalid";
let in_path = paths
.first()
.expect(invalid_path_message)
.strip_prefix(&current_dir())
.expect(invalid_path_message)
.to_str()
.expect(invalid_path_message);
let in_path = format!("./{}", in_path);
let result = docki_build(&in_path, false);
match result {
DockiBuildResult::Slide(out_path) => display_rebuilding_status("Slide", &in_path, &out_path),
DockiBuildResult::Doc(out_path) => display_rebuilding_status("Doc", &in_path, &out_path),
DockiBuildResult::Copy(out_path) => display_rebuilding_status("Copy", &in_path, &out_path),
DockiBuildResult::Err(err) => {
display_rebuilding_status("Error", &in_path, "");
println!("{}", err);
},
DockiBuildResult::Silent => ()
}
}
fn display_rebuilding_status(context: &str, in_path: &str, out_path: &str) {
display_status("Rebuildng", context, in_path, out_path)

View File

@@ -1,9 +1,27 @@
use clap::{Parser, Subcommand};
use nu_ansi_term::{AnsiGenericString, Style};
fn github_hyperlink() -> AnsiGenericString<'static, str> {
return Style::new()
.bold()
.underline()
.paint("https://github.com/quirinecker/docki")
.hyperlink("https://github.com/quirinecker/docki");
}
#[derive(Parser)]
#[command(after_help = format!("More information like defaults can be found at {}", github_hyperlink()))]
pub struct Args {
#[command(subcommand)]
pub command: CommandArg,
/// The directory where the documentation is located
#[arg(short, long, global = true)]
pub input_dir: Option<String>,
/// The directory where the documentation will be built
#[arg(short, long, global = true)]
pub output_dir: Option<String>,
}
#[derive(Subcommand)]
@@ -17,8 +35,8 @@ pub enum ShellArg {
pub enum CommandArg {
/// Builds the documentation into a dist folder
Build {
/// When set to true, docki will download revealjs before building the documentation.
/// Otherwise it will use the cdn for revealjs
/// When set to true, docki will download revealjs before building the documentation.
/// Otherwise it will use the cdn for revealjs
#[arg(short, long)]
offline_reveal: bool,
},
@@ -38,3 +56,5 @@ pub enum CommandArg {
shell: ShellArg,
},
}
impl Args {}

50
src/app/config/config.rs Normal file
View File

@@ -0,0 +1,50 @@
use serde::Deserialize;
use crate::app::config::arguments::CommandArg;
#[derive(Deserialize, Debug)]
#[serde(default)]
pub struct Config {
pub port: u16,
pub input_dir: String,
pub offline_reveal: bool,
pub output_dir: String
}
impl Config {
pub fn load() -> Result<Self, config::ConfigError> {
let s = config::Config::builder()
.add_source(config::File::with_name("./docki.config.toml"))
.build()?;
s.try_deserialize()
}
pub fn merge_with_args(self, args: &super::arguments::Args) -> Self {
Self {
port: match args.command {
CommandArg::Serve { port } => port.unwrap_or(self.port),
_ => self.port,
},
input_dir: args.input_dir.clone().unwrap_or(self.input_dir),
output_dir: args.output_dir.clone().unwrap_or(self.output_dir),
offline_reveal: {
if let CommandArg::Build { offline_reveal } = args.command {
offline_reveal
} else {
self.offline_reveal
}
},
}
}
}
impl Default for Config {
fn default() -> Self {
Self {
port: 8080,
input_dir: "./docs".to_string(),
output_dir: "./dist".to_string(),
offline_reveal: false,
}
}
}

View File

@@ -1,10 +1,10 @@
use clap::Parser;
use self::structure::Args;
use self::arguments::Args;
pub mod structure;
pub mod arguments;
pub mod config;
pub fn args() -> Args {
return Args::parse();
}

View File

@@ -1,20 +1,19 @@
use colored::Colorize;
use nu_ansi_term::Color::LightGreen;
use nu_ansi_term::Color::LightRed;
use nu_ansi_term::Style;
pub fn display_status(context1: &str, context2: &str, in_path: &str, out_path: &str) {
let colored_context = color_context(context2);
let colored_context = if context2 == "Error" {
LightRed.paint(context2)
} else {
LightGreen.paint(context2)
};
println!(
"({}) [{}] {} -> {}",
context1.bold(),
Style::new().paint(context1),
colored_context,
in_path,
out_path
);
}
fn color_context(context: &str) -> colored::ColoredString {
if context == "Error" {
return context.bright_red()
} else {
return context.bright_green()
}
}

View File

@@ -3,11 +3,13 @@ pub mod build;
pub mod fs_util;
pub mod watcher;
pub mod log;
mod args;
mod config;
use std::env;
use self::args::{args, structure::CommandArg};
use crate::app::config::config::Config;
use self::config::{args, arguments::CommandArg};
use self::commands::build::build;
use self::commands::completions::completions;
use self::commands::health::health;
@@ -20,13 +22,14 @@ impl App {
pub async fn start(&self) {
let args = args();
let config = Config::load().unwrap_or(Config::default()).merge_with_args(&args);
Self::setup_environment_variables();
match args.command {
CommandArg::Build { offline_reveal } => build(offline_reveal).await,
CommandArg::Build { .. } => build(&config).await,
CommandArg::Health => health(),
CommandArg::InstallReveal => install_reveal().await,
CommandArg::Serve { port } => serve(port).await,
CommandArg::Serve { .. } => serve(&config).await,
CommandArg::Completions { shell } => completions(shell)
};
}