From 0cfa806b6d423af4ac81c8634ecf35ed31afffc1 Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:04:26 +0200 Subject: [PATCH 01/15] Minor cleanup --- src/generation.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/generation.rs b/src/generation.rs index 1a9192a..210a741 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -60,6 +60,19 @@ impl Template { Template { path: buf } } + fn render_template( + &self, + content: &str, + context: &Context, + path: Option, + ) -> Result { + let mut tera = Tera::default(); + + tera.add_raw_template("one_off", content) + .and_then(|_| tera.render("one_off", context)) + .map_err(|err| new_error(ErrorKind::Tera { err, path })) + } + /// Generate the template at the given output directory pub fn generate(&self, output_dir: &Path, no_input: bool) -> Result<()> { // Get the variables from the user first @@ -145,7 +158,7 @@ impl Template { continue; } - let contents = render_one_off_template( + let contents = self.render_template( &str::from_utf8(&buffer).unwrap(), &context, Some(entry.path().to_path_buf()), From 2563e234a19df899c5b1ff10a1823584dfaa15d1 Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:07:03 +0200 Subject: [PATCH 02/15] Add keywords --- Cargo.lock | 597 ++++++++++++++++++++++++++++++++-------------- Cargo.toml | 8 +- src/definition.rs | 14 +- src/generation.rs | 2 +- 4 files changed, 435 insertions(+), 186 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eecf1d2..ac5882d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,27 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] @@ -33,57 +42,46 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.7.3" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - [[package]] name = "bstr" -version = "0.2.16" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" +checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" dependencies = [ "memchr", + "serde", ] [[package]] -name = "byte-tools" -version = "0.3.1" +name = "bumpalo" +version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] -name = "byteorder" -version = "1.4.3" +name = "cc" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" [[package]] name = "cfg-if" @@ -93,32 +91,43 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ - "libc", + "iana-time-zone", "num-integer", "num-traits", - "time", "winapi", ] [[package]] name = "chrono-tz" -version = "0.5.3" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2554a3155fec064362507487171dcc4edc3df60cb10f3a1fb10ed8094822b120" +checksum = "29c39203181991a7dd4343b8005bd804e7a9a37afb8ac070e43771e8c820bbde" dependencies = [ "chrono", + "chrono-tz-build", + "phf", +] + +[[package]] +name = "chrono-tz-build" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f509c3a87b33437b05e2458750a0700e5bdd6956176773e6c7d6dd15a283a0c" +dependencies = [ "parse-zoneinfo", + "phf", + "phf_codegen", ] [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -130,13 +139,82 @@ dependencies = [ ] [[package]] -name = "crossbeam-utils" -version = "0.8.5" +name = "codespan-reporting" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ - "cfg-if", - "lazy_static", + "termcolor", + "unicode-width", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cxx" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d1075c37807dcf850c379432f0df05ba52cc30f279c5cfc43cc221ce7f8579" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5044281f61b27bc598f2f6647d480aed48d2bf52d6eb0b627d84c0361b17aa70" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b50bc93ba22c27b0d31128d2d130a0a6b3d267ae27ef7e4fae2167dfe8781c" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e61fda7e62115119469c7b3591fd913ecca96fb766cfd3f2e2502ab7bc87a5" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -147,11 +225,12 @@ checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" [[package]] name = "digest" -version = "0.8.1" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "generic-array", + "block-buffer", + "crypto-common", ] [[package]] @@ -176,10 +255,13 @@ dependencies = [ ] [[package]] -name = "fake-simd" -version = "0.1.2" +name = "fastrand" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] [[package]] name = "fnv" @@ -189,18 +271,19 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" -version = "0.12.4" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", + "version_check", ] [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -209,15 +292,15 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd" +checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ "aho-corasick", "bstr", @@ -252,13 +335,36 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "ignore" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" +checksum = "a05705bc64e0b66a806c3740bd6578ea66051b157ec42dc219c785cbf185aef3" dependencies = [ - "crossbeam-utils", "globset", "lazy_static", "log", @@ -270,11 +376,29 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + [[package]] name = "itoa" -version = "0.4.7" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "js-sys" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] [[package]] name = "kickstart" @@ -300,36 +424,39 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.98" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] -name = "log" -version = "0.4.14" +name = "link-cplusplus" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ - "cfg-if", + "cc", ] [[package]] -name = "maplit" -version = "1.0.2" +name = "log" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] [[package]] name = "memchr" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -337,24 +464,18 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" - -[[package]] -name = "opaque-debug" -version = "0.2.3" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "parse-zoneinfo" @@ -367,24 +488,25 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.1.3" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "4257b4a04d91f7e9e6290be5d3da4804dd5784fafde3a497d73eb2b4a158c30a" dependencies = [ + "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.1.0" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +checksum = "241cda393b0cdd65e62e07e12454f1f25d57017dcc514b1514cd3c4645e3a0a6" dependencies = [ "pest", "pest_generator", @@ -392,9 +514,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.1.3" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +checksum = "46b53634d8c8196302953c74d5352f33d0c512a9499bd2ce468fc9f4128fa27c" dependencies = [ "pest", "pest_meta", @@ -405,49 +527,87 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.1.3" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +checksum = "0ef4f1332a8d4678b41966bb4cc1d0676880e84183a1ecc3f4b69f03e99c7a51" dependencies = [ - "maplit", + "once_cell", "pest", - "sha-1", + "sha2", +] + +[[package]] +name = "phf" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56ac890c5e3ca598bbdeaa99964edb5b0258a583a9eb6ef4e89fc85d9224770" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" +dependencies = [ + "siphasher", + "uncased", ] [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] [[package]] name = "rand" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", "rand_core", - "rand_hc", ] [[package]] @@ -462,46 +622,38 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core", -] - [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", "redox_syscall", + "thiserror", ] [[package]] name = "regex" -version = "1.5.4" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -510,9 +662,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "remove_dir_all" @@ -525,15 +677,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "same-file" @@ -544,20 +696,26 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + [[package]] name = "serde" -version = "1.0.126" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -566,9 +724,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" dependencies = [ "itoa", "ryu", @@ -576,17 +734,22 @@ dependencies = [ ] [[package]] -name = "sha-1" -version = "0.8.2" +name = "sha2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ - "block-buffer", + "cfg-if", + "cpufeatures", "digest", - "fake-simd", - "opaque-debug", ] +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + [[package]] name = "slug" version = "0.1.4" @@ -604,24 +767,24 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.73" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", + "fastrand", "libc", - "rand", "redox_syscall", "remove_dir_all", "winapi", @@ -629,9 +792,9 @@ dependencies = [ [[package]] name = "tera" -version = "1.12.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7571541dff0e57eaa2e931249f0d7489eb2b24b6b105546f8c2f1a47f15aaa3a" +checksum = "3df578c295f9ec044ff1c829daf31bb7581d5b3c2a7a3d87419afe1f2531438c" dependencies = [ "chrono", "chrono-tz", @@ -660,6 +823,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -670,44 +842,63 @@ dependencies = [ ] [[package]] -name = "thread_local" -version = "1.1.3" +name = "thiserror" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ - "once_cell", + "thiserror-impl", ] [[package]] -name = "time" -version = "0.1.43" +name = "thiserror-impl" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ - "libc", - "winapi", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", ] [[package]] name = "toml" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" dependencies = [ "serde", ] [[package]] name = "typenum" -version = "1.13.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + +[[package]] +name = "uncased" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b01702b0fd0b3fadcf98e098780badda8742d4f4a7676615cad90e8ac73622" +dependencies = [ + "version_check", +] [[package]] name = "unic-char-property" @@ -760,16 +951,16 @@ dependencies = [ ] [[package]] -name = "unicode-width" -version = "0.1.8" +name = "unicode-ident" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-width" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "vec_map" @@ -777,6 +968,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "walkdir" version = "2.3.2" @@ -790,9 +987,63 @@ dependencies = [ [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "winapi" diff --git a/Cargo.toml b/Cargo.toml index 8b50f69..9792d00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] +name = "kickstart" +description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" authors = ["Vincent Prouillet "] -description = "A simple way to get started with a project by scaffolding from a template powered by the Tera engine" edition = "2018" keywords = ["tera", "scaffolding", "templating", "generator", "boilerplate"] license = "MIT" -name = "kickstart" version = "0.3.0" [dependencies] @@ -12,7 +12,7 @@ clap = "2" glob = "0.3" memchr = "2" regex = "1" -serde = {version = "1", features = ["derive"]} +serde = { version = "1", features = ["derive"] } tera = "1" term = "0.7" toml = "0.5" @@ -22,4 +22,4 @@ walkdir = "2" tempfile = "3" [badges] -maintenance = {status = "actively-developed"} +maintenance = { status = "actively-developed" } diff --git a/src/definition.rs b/src/definition.rs index 77140da..042fa2f 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -1,13 +1,11 @@ -use std::collections::{HashMap}; - -use regex::{Regex, Match}; use serde::Deserialize; -use tera::{Context}; +use std::collections::HashMap; +use tera::Context; use toml::Value; use crate::errors::{new_error, ErrorKind, Result}; use crate::prompt::{ask_bool, ask_choices, ask_integer, ask_string}; -use crate::utils::{render_one_off_template}; +use crate::utils::render_one_off_template; /// A condition for a question to be asked #[derive(Debug, Clone, PartialEq, Deserialize)] @@ -125,7 +123,7 @@ impl TemplateDefinition { let rendered_default = render_one_off_template(&s, &context, None); match rendered_default { Err(e) => return Err(e), - Ok(v ) => v, + Ok(v) => v, } } else { s.clone() @@ -303,7 +301,7 @@ mod tests { assert_eq!(tpl.variables.len(), 3); let res = tpl.ask_questions(true); - + assert!(res.is_ok()); let res = res.unwrap(); @@ -314,6 +312,6 @@ mod tests { let got_value = res.get("manifest").unwrap(); let expected_value: String = String::from("my_project-other_project-manifest.md"); - assert_eq!(got_value, &Value::String(expected_value)) + assert_eq!(got_value, &Value::String(expected_value)) } } diff --git a/src/generation.rs b/src/generation.rs index 210a741..806df2f 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -6,7 +6,7 @@ use std::process::Command; use std::str; use glob::Pattern; -use tera::{Context}; +use tera::{Context, Tera}; use walkdir::WalkDir; use crate::definition::TemplateDefinition; From b976d3793e6f7d4749300896914ca7a4f31bd9a4 Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:08:07 +0200 Subject: [PATCH 03/15] Cleanup --- Cargo.toml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9792d00..0957aa5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,17 @@ [package] -name = "kickstart" -description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" authors = ["Vincent Prouillet "] +description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" edition = "2018" -keywords = ["tera", "scaffolding", "templating", "generator", "boilerplate"] license = "MIT" +name = "kickstart" +keywords = [ + "rust", + "tera", + "scaffolding", + "templating", + "generator", + "boilerplate", +] version = "0.3.0" [dependencies] From 6257e0c87a32b3942317d8ad1c7f7e759683477d Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:09:08 +0200 Subject: [PATCH 04/15] Add a quick check wortkflow --- .github/workflows/quick-check.yml | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/quick-check.yml diff --git a/.github/workflows/quick-check.yml b/.github/workflows/quick-check.yml new file mode 100644 index 0000000..0794054 --- /dev/null +++ b/.github/workflows/quick-check.yml @@ -0,0 +1,66 @@ +# This workflow runs on every push and checks whether everything looks good + +name: Quick check + +on: + push: + tags-ignore: + - v* + pull_request: + types: [opened, synchronize, reopened] + + workflow_dispatch: + +jobs: + quick_check-format: + runs-on: ubuntu-latest + steps: + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt + + - uses: actions/checkout@v2 + + - name: Cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + quick_check-clippy: + runs-on: ubuntu-latest + steps: + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: clippy + + - uses: actions/checkout@v2 + + - name: Cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + quick_check-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + - name: Cargo check + uses: actions-rs/cargo@v1 + with: + command: check From 4dbddf4ebad6d71772d2a81eaeb2bbf188771414 Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:48:55 +0200 Subject: [PATCH 05/15] fix spelling --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0957aa5..a291a2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] authors = ["Vincent Prouillet "] -description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" +description = "A simple way to get started with a project by scaffolding from a template powered by the Tera engine" edition = "2018" license = "MIT" name = "kickstart" From 920a672ff83630dd7cc67fa075d4b1c81f617a18 Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:49:07 +0200 Subject: [PATCH 06/15] remove gihub ci --- .github/workflows/quick-check.yml | 66 ------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 .github/workflows/quick-check.yml diff --git a/.github/workflows/quick-check.yml b/.github/workflows/quick-check.yml deleted file mode 100644 index 0794054..0000000 --- a/.github/workflows/quick-check.yml +++ /dev/null @@ -1,66 +0,0 @@ -# This workflow runs on every push and checks whether everything looks good - -name: Quick check - -on: - push: - tags-ignore: - - v* - pull_request: - types: [opened, synchronize, reopened] - - workflow_dispatch: - -jobs: - quick_check-format: - runs-on: ubuntu-latest - steps: - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt - - - uses: actions/checkout@v2 - - - name: Cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - quick_check-clippy: - runs-on: ubuntu-latest - steps: - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: clippy - - - uses: actions/checkout@v2 - - - name: Cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings - - quick_check-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Cargo test - uses: actions-rs/cargo@v1 - with: - command: test - - - name: Cargo check - uses: actions-rs/cargo@v1 - with: - command: check From f764ffe18c10c54bbc123e61d28d42e18286313e Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:07:03 +0200 Subject: [PATCH 07/15] Add keywords --- Cargo.toml | 4 ++-- src/generation.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a291a2d..0f4ac5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] +name = "kickstart" +description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" authors = ["Vincent Prouillet "] -description = "A simple way to get started with a project by scaffolding from a template powered by the Tera engine" edition = "2018" license = "MIT" -name = "kickstart" keywords = [ "rust", "tera", diff --git a/src/generation.rs b/src/generation.rs index 806df2f..59639e9 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -60,7 +60,7 @@ impl Template { Template { path: buf } } - fn render_template( + fn _render_template( &self, content: &str, context: &Context, @@ -158,7 +158,7 @@ impl Template { continue; } - let contents = self.render_template( + let contents = render_one_off_template( &str::from_utf8(&buffer).unwrap(), &context, Some(entry.path().to_path_buf()), From b0cb0aabe2cad39deb0776c63bbf70e602d09617 Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:08:07 +0200 Subject: [PATCH 08/15] Cleanup --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0f4ac5f..1283966 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kickstart" -description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" authors = ["Vincent Prouillet "] +description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" edition = "2018" license = "MIT" keywords = [ From 00e664ce2e5eb4b7d8295955c9e4c5b5077f148f Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:48:55 +0200 Subject: [PATCH 09/15] fix spelling --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1283966..15092f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kickstart" authors = ["Vincent Prouillet "] -description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" +description = "A simple way to get started with a project by scaffolding from a template powered by the Tera engine" edition = "2018" license = "MIT" keywords = [ From faf4ab14bd82422257a0a31b95e323b819b01256 Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:07:03 +0200 Subject: [PATCH 10/15] Add keywords --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 15092f0..0f4ac5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kickstart" +description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" authors = ["Vincent Prouillet "] -description = "A simple way to get started with a project by scaffolding from a template powered by the Tera engine" edition = "2018" license = "MIT" keywords = [ From c12212a010713f0d2357bc59141aa0c1f03c62c3 Mon Sep 17 00:00:00 2001 From: chevdor Date: Wed, 30 Jun 2021 12:08:07 +0200 Subject: [PATCH 11/15] Cleanup --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0f4ac5f..0957aa5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "kickstart" -description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" authors = ["Vincent Prouillet "] +description = "A simple way to get started with a project by scaffolding from a template powered by the tera engine" edition = "2018" license = "MIT" +name = "kickstart" keywords = [ "rust", "tera", From 48f58c3e120b1ee5ab49fc7ed0238ec415049673 Mon Sep 17 00:00:00 2001 From: Chevdor Date: Thu, 12 Jan 2023 11:53:50 +0100 Subject: [PATCH 12/15] WIP --- Cargo.lock | 200 +++++++++++++++++++++++++++++++++---------- Cargo.toml | 2 +- src/bin/kickstart.rs | 51 +++++------ 3 files changed, 182 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac5882d..50864b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,26 +20,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -125,17 +105,27 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" +version = "4.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" dependencies = [ - "ansi_term", - "atty", "bitflags", + "clap_lex", + "is-terminal", + "once_cell", "strsim", - "textwrap", + "termcolor", + "unicase", "unicode-width", - "vec_map", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", ] [[package]] @@ -254,6 +244,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "fastrand" version = "1.8.0" @@ -322,9 +333,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" dependencies = [ "libc", ] @@ -385,6 +396,28 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + [[package]] name = "itoa" version = "1.0.5" @@ -437,6 +470,12 @@ dependencies = [ "cc", ] +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "log" version = "0.4.17" @@ -477,6 +516,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + [[package]] name = "parse-zoneinfo" version = "0.3.0" @@ -675,6 +720,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "rustversion" version = "1.0.11" @@ -761,9 +820,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -832,15 +891,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.38" @@ -950,6 +1000,15 @@ dependencies = [ "unic-common", ] +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-ident" version = "1.0.6" @@ -962,12 +1021,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" -[[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" @@ -1075,3 +1128,60 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" diff --git a/Cargo.toml b/Cargo.toml index 0957aa5..04c4a09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ keywords = [ version = "0.3.0" [dependencies] -clap = "2" +clap = { version = "4", features = ["env", "unicode", "cargo"] } glob = "0.3" memchr = "2" regex = "1" diff --git a/src/bin/kickstart.rs b/src/bin/kickstart.rs index b9109fe..7cb8adc 100644 --- a/src/bin/kickstart.rs +++ b/src/bin/kickstart.rs @@ -2,45 +2,46 @@ use std::env; use std::error::Error; use std::path::Path; -use clap::{crate_authors, crate_description, crate_version, App, AppSettings, Arg, SubCommand}; +use clap::{arg, command, Command}; use kickstart::generation::Template; use kickstart::terminal; use kickstart::validate::validate_file; -pub fn build_cli() -> App<'static, 'static> { - App::new("kickstart") - .version(crate_version!()) - .author(crate_authors!()) - .about(crate_description!()) - .setting(AppSettings::SubcommandsNegateReqs) +pub fn build_cli() -> Command { + command!() + .arg(arg!("kickstart")) + // .about(crate_description!()) + // .setting(AppSettings::SubcommandsNegateReqs) .arg( - Arg::with_name("template") + arg!([name] "template") .required(true) .help("Template to use: a local path or a HTTP url pointing to a Git repository"), ) .arg( - Arg::with_name("output-dir") - .short("o") + arg!([name] "output-dir") + .short('o') .long("output-dir") - .takes_value(true) + .num_args(1) .help("Where to output the project: defaults to the current directory"), ) .arg( - Arg::with_name("sub-dir") - .short("s") + arg!([name] "sub-dir") + .short('s') .long("sub-dir") - .takes_value(true) + .num_args(1) .help("A subdirectory of the chosen template to use, to allow nested templates."), ) .arg( - Arg::with_name("no-input") + arg!([name] "no-input") .long("no-input") .help("Do not prompt for parameters and only use the defaults from template.toml"), ) - .subcommands(vec![SubCommand::with_name("validate") - .about("Validates that a template.toml is valid") - .arg(Arg::with_name("path").required(true).help("The path to the template.toml"))]) + .subcommand( + Command::new("validate") + .about("Validates that a template.toml is valid") + .arg(arg!([name] "path").required(true).help("The path to the template.toml")), + ) } fn bail(e: &dyn Error) -> ! { @@ -57,8 +58,8 @@ fn main() { let matches = build_cli().get_matches(); match matches.subcommand() { - ("validate", Some(matches)) => { - let errs = match validate_file(matches.value_of("path").unwrap()) { + Some(("validate", sub_matches)) => { + let errs = match validate_file(sub_matches.get_one::("path").unwrap()) { Ok(e) => e, Err(e) => bail(&e), }; @@ -75,15 +76,15 @@ fn main() { } _ => { // The actual generation call - let template_path = matches.value_of("template").unwrap(); + let template_path = matches.get_one::("template").unwrap(); let output_dir = matches - .value_of("output-dir") + .get_one::("output-dir") .map(|p| Path::new(p).to_path_buf()) .unwrap_or_else(|| env::current_dir().unwrap()); - let no_input = matches.is_present("no-input"); - let sub_dir = matches.value_of("sub-dir"); + let no_input = matches.get_one::("no-input").is_some(); + let sub_dir = matches.get_one::("sub-dir"); - let template = match Template::from_input(template_path, sub_dir) { + let template = match Template::from_input(template_path, sub_dir.map(|x| &**x)) { Ok(t) => t, Err(e) => bail(&e), }; From a3f7375e40fec7d024373a879a08c97e25e53b1e Mon Sep 17 00:00:00 2001 From: Chevdor Date: Thu, 12 Jan 2023 14:25:52 +0100 Subject: [PATCH 13/15] Fix string formatting --- src/bin/kickstart.rs | 6 +++--- src/definition.rs | 4 ++-- src/errors.rs | 10 +++++----- src/generation.rs | 34 +++++++++++++++++----------------- src/prompt.rs | 12 ++++++------ src/terminal.rs | 36 ++++++++++++++++++------------------ src/validate.rs | 2 +- 7 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/bin/kickstart.rs b/src/bin/kickstart.rs index 7cb8adc..2edd349 100644 --- a/src/bin/kickstart.rs +++ b/src/bin/kickstart.rs @@ -45,10 +45,10 @@ pub fn build_cli() -> Command { } fn bail(e: &dyn Error) -> ! { - terminal::error(&format!("Error: {}", e)); + terminal::error(&format!("Error: {e}")); let mut cause = e.source(); while let Some(e) = cause { - terminal::error(&format!("Reason: {}", e)); + terminal::error(&format!("Reason: {e}")); cause = e.source(); } ::std::process::exit(1) @@ -67,7 +67,7 @@ fn main() { if !errs.is_empty() { terminal::error("The template.toml is invalid:\n"); for err in errs { - terminal::error(&format!("- {}\n", err)); + terminal::error(&format!("- {err}\n")); } ::std::process::exit(1); } else { diff --git a/src/definition.rs b/src/definition.rs index 042fa2f..7291d83 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -120,7 +120,7 @@ impl TemplateDefinition { context.insert(key, val); } - let rendered_default = render_one_off_template(&s, &context, None); + let rendered_default = render_one_off_template(s, &context, None); match rendered_default { Err(e) => return Err(e), Ok(v) => v, @@ -153,7 +153,7 @@ impl TemplateDefinition { #[cfg(test)] mod tests { - use toml; + use super::*; diff --git a/src/errors.rs b/src/errors.rs index c893cf8..2534362 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -87,16 +87,16 @@ impl StdError for Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.kind { - ErrorKind::Io { ref err, ref path } => write!(f, "{}: {:?}", err, path), + ErrorKind::Io { ref err, ref path } => write!(f, "{err}: {path:?}"), ErrorKind::Tera { ref err, ref path } => { if let Some(p) = path { - write!(f, "{}: {:?}", err, p) + write!(f, "{err}: {p:?}") } else { - write!(f, "{}: rendering a one-off template", err) + write!(f, "{err}: rendering a one-off template") } } - ErrorKind::Git { ref err } => write!(f, "Could not clone the repository: {}", err), - ErrorKind::Toml { ref err } => write!(f, "Invalid TOML: {}", err), + ErrorKind::Git { ref err } => write!(f, "Could not clone the repository: {err}"), + ErrorKind::Toml { ref err } => write!(f, "Invalid TOML: {err}"), ErrorKind::MissingTemplateDefinition => write!(f, "The template.toml is missing"), ErrorKind::UnreadableStdin => write!(f, "Unable to read from stdin"), ErrorKind::InvalidTemplate => write!(f, "The template.toml is invalid"), diff --git a/src/generation.rs b/src/generation.rs index 59639e9..9f66bb0 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -36,7 +36,7 @@ impl Template { pub fn from_git(remote: &str, sub_dir: Option<&str>) -> Result