diff --git a/Cargo.lock b/Cargo.lock index ec8cb68..47a033b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,13 +3,10 @@ version = 3 [[package]] -name = "aho-corasick" -version = "0.7.20" +name = "android-tzdata" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" [[package]] name = "android_system_properties" @@ -22,100 +19,103 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys", ] [[package]] -name = "autocfg" -version = "1.1.0" +name = "askama_parser" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0" +dependencies = [ + "nom", +] [[package]] -name = "bitflags" -version = "1.3.2" +name = "autocfg" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] [[package]] -name = "bstr" -version = "1.1.0" +name = "bumpalo" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" -dependencies = [ - "memchr", - "serde", -] +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] -name = "bumpalo" -version = "3.11.1" +name = "byteorder" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.3.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.0.78" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -125,55 +125,32 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", - "time", "wasm-bindgen", - "winapi", -] - -[[package]] -name = "chrono-tz" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -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", + "windows-targets", ] [[package]] name = "clap" -version = "4.4.6" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", @@ -183,46 +160,36 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.3" +version = "4.5.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7" +checksum = "9340e41703683548f486fdfdce615b0520dd220d18b1d4ce5abbc87d461c221b" dependencies = [ "clap", ] [[package]] name = "clap_lex" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" - -[[package]] -name = "codespan-reporting" -version = "0.11.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -237,61 +204,17 @@ dependencies = [ "typenum", ] -[[package]] -name = "cxx" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "deunicode" -version = "0.4.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -299,15 +222,17 @@ dependencies = [ [[package]] name = "fake" -version = "2.5.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d68f517805463f3a896a9d29c1d6ff09d3579ded64a7201b4069f8f9c0d52fd" +checksum = "1c25829bde82205da46e1823b2259db6273379f626fc211f126f65654a2669be" dependencies = [ "chrono", - "http", + "deunicode", + "http 1.1.0", "rand 0.8.5", "random_color", "semver", + "url-escape", ] [[package]] @@ -318,9 +243,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -339,9 +264,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -349,193 +274,142 @@ dependencies = [ ] [[package]] -name = "globset" -version = "0.4.10" +name = "http" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ - "aho-corasick", - "bstr", + "bytes", "fnv", - "log", - "regex", -] - -[[package]] -name = "globwalk" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" -dependencies = [ - "bitflags", - "ignore", - "walkdir", + "itoa", ] [[package]] name = "http" -version = "0.2.8" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", "itoa", ] -[[package]] -name = "humansize" -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" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows-core", ] [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] -name = "ignore" -version = "0.4.19" +name = "is_terminal_polyfill" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a05705bc64e0b66a806c3740bd6578ea66051b157ec42dc219c785cbf185aef3" -dependencies = [ - "globset", - "lazy_static", - "log", - "memchr", - "regex", - "same-file", - "thread_local", - "walkdir", - "winapi-util", -] +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.140" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] -name = "link-cplusplus" -version = "1.0.8" +name = "log" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] -name = "log" -version = "0.4.17" +name = "memchr" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "memchr" -version = "2.5.0" +name = "minimal-lexical" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] -name = "num-integer" -version = "0.1.45" +name = "nom" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ - "autocfg", - "num-traits", + "memchr", + "minimal-lexical", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" - -[[package]] -name = "parse-zoneinfo" -version = "0.3.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" -dependencies = [ - "regex", -] +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.5.2" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6e86fb9e7026527a0d46bc308b841d73170ef8f443e1807f6ef88526a816d4" +checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" dependencies = [ + "memchr", "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.5.2" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96504449aa860c8dcde14f9fba5c58dc6658688ca1fe363589d6327b8662c603" +checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" dependencies = [ "pest", "pest_generator", @@ -543,9 +417,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.5.2" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "798e0220d1111ae63d66cb66a5dcb3fc2d986d520b98e49e1852bfdb11d7c5e7" +checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" dependencies = [ "pest", "pest_meta", @@ -556,93 +430,59 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.5.2" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "984298b75898e30a843e278a9f2452c31e349a073a0ce6fd950a12a74464e065" +checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" dependencies = [ "once_cell", "pest", - "sha1", -] - -[[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 0.8.5", -] - -[[package]] -name = "phf_shared" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" -dependencies = [ - "siphasher", - "uncased", + "sha2", ] [[package]] name = "pouf" version = "0.6.3" dependencies = [ + "askama_parser", "chrono", "clap", "clap_complete", "fake", - "http", + "http 0.2.12", "pest", "pest_derive", + "proc-macro2", "rand 0.8.5", "random_color", "semver", "serde", - "tera", + "syn", "unidecode", ] [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -707,7 +547,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.15", ] [[package]] @@ -737,64 +577,26 @@ dependencies = [ "rand 0.7.3", ] -[[package]] -name = "regex" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "ryu" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "scratch" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" - [[package]] name = "semver" -version = "1.0.16" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", @@ -802,21 +604,10 @@ dependencies = [ ] [[package]] -name = "serde_json" -version = "1.0.91" +name = "sha2" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -824,190 +615,65 @@ dependencies = [ ] [[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" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" -dependencies = [ - "deunicode", -] +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "1.0.107" +version = "2.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tera" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df578c295f9ec044ff1c829daf31bb7581d5b3c2a7a3d87419afe1f2531438c" -dependencies = [ - "chrono", - "chrono-tz", - "globwalk", - "humansize", - "lazy_static", - "percent-encoding", - "pest", - "pest_derive", - "rand 0.8.5", - "regex", - "serde", - "serde_json", - "slug", - "unic-segment", -] - -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "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 = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -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" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" -dependencies = [ - "unic-char-range", -] - -[[package]] -name = "unic-char-range" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" - -[[package]] -name = "unic-common" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" - -[[package]] -name = "unic-segment" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" -dependencies = [ - "unic-ucd-segment", -] - -[[package]] -name = "unic-ucd-segment" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" -dependencies = [ - "unic-char-property", - "unic-char-range", - "unic-ucd-version", -] - -[[package]] -name = "unic-ucd-version" -version = "0.9.0" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" -dependencies = [ - "unic-common", -] +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "unicode-width" -version = "0.1.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unidecode" @@ -1016,27 +682,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "402bb19d8e03f1d1a7450e2bd613980869438e0666331be3e073089124aa1adc" [[package]] -name = "utf8parse" -version = "0.2.1" +name = "url-escape" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "44e0ce4d1246d075ca5abec4b41d33e87a6054d08e2366b63205665e950db218" +dependencies = [ + "percent-encoding", +] [[package]] -name = "version_check" -version = "0.9.4" +name = "utf8parse" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] -name = "walkdir" -version = "2.3.2" +name = "version_check" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi", - "winapi-util", -] +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -1044,12 +708,6 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1058,19 +716,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -1083,9 +742,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1093,9 +752,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -1106,59 +765,38 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", + "windows-targets", ] -[[package]] -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.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -1167,42 +805,69 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 747aceb..febcc3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,10 @@ rand = "0.8" serde = { version = "1.0", features = ["derive"] } pest = "2.5" pest_derive = "2.5" -tera = "1.17" + +proc-macro2 = "1" +syn = "^2" +askama_parser = "0.2" [build-dependencies] clap = { version="4.4", features=['cargo'] } diff --git a/_pouf b/_pouf index 8a6c2c0..76abefe 100644 --- a/_pouf +++ b/_pouf @@ -14,7 +14,7 @@ _pouf() { fi local context curcontext="$curcontext" state line - _arguments "${_arguments_options[@]}" \ + _arguments "${_arguments_options[@]}" : \ '-h[Print help]' \ '--help[Print help]' \ '-V[Print version]' \ @@ -29,7 +29,7 @@ _pouf() { curcontext="${curcontext%:*:*}:pouf-command-$line[1]:" case $line[1] in (template) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-i+[give an input template file (tera \: https\://tera.netlify.app/)]: :_files' \ '--input=[give an input template file (tera \: https\://tera.netlify.app/)]: :_files' \ '-n+[number of values]: : ' \ @@ -39,7 +39,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (address.city) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -47,7 +47,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (address.country) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -55,7 +55,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (address.street) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -63,7 +63,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (administrative.healthinsurrancecode) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -71,7 +71,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (auto.licenseplate) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -79,7 +79,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (barcode.isbn) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -87,7 +87,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (color) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-d[give a fake hexadecimal color]' \ @@ -105,7 +105,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (filesystem.mimetype) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -113,7 +113,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (filesystem.semver) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-s[give exclusivly stable semver version (X.Y.Z)]' \ @@ -125,7 +125,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (finance.bic) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -133,7 +133,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (http.code) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-l+[give lang (ie\: fr_FR)]: :(fr fr_FR en)' \ '--lang=[give lang (ie\: fr_FR)]: :(fr fr_FR en)' \ '-n+[number of values]: : ' \ @@ -143,7 +143,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (internet.ip) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-4[give exclusivly IPv4]' \ @@ -155,7 +155,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (internet.mac) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -163,7 +163,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (internet.mail) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -171,7 +171,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (internet.useragent) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -179,7 +179,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (lorem.word) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -187,7 +187,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (people.name) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-l+[give lang (ie\: fr_FR)]: :(fr fr_FR en)' \ '--lang=[give lang (ie\: fr_FR)]: :(fr fr_FR en)' \ '-n+[number of values]: : ' \ @@ -205,7 +205,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (time.time) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -213,7 +213,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (time.date) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ '-n+[number of values]: : ' \ '--number=[number of values]: : ' \ '-h[Print help]' \ @@ -221,7 +221,7 @@ _arguments "${_arguments_options[@]}" \ && ret=0 ;; (help) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ ":: :_pouf__help_commands" \ "*::: :->help" \ && ret=0 @@ -233,87 +233,87 @@ _arguments "${_arguments_options[@]}" \ curcontext="${curcontext%:*:*}:pouf-help-command-$line[1]:" case $line[1] in (template) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (address.city) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (address.country) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (address.street) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (administrative.healthinsurrancecode) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (auto.licenseplate) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (barcode.isbn) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (color) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (filesystem.mimetype) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (filesystem.semver) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (finance.bic) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (http.code) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (internet.ip) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (internet.mac) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (internet.mail) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (internet.useragent) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (lorem.word) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (people.name) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (time.time) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (time.date) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; (help) -_arguments "${_arguments_options[@]}" \ +_arguments "${_arguments_options[@]}" : \ && ret=0 ;; esac @@ -357,101 +357,51 @@ _pouf__address.city_commands() { local commands; commands=() _describe -t commands 'pouf address.city commands' commands "$@" } -(( $+functions[_pouf__help__address.city_commands] )) || -_pouf__help__address.city_commands() { - local commands; commands=() - _describe -t commands 'pouf help address.city commands' commands "$@" -} (( $+functions[_pouf__address.country_commands] )) || _pouf__address.country_commands() { local commands; commands=() _describe -t commands 'pouf address.country commands' commands "$@" } -(( $+functions[_pouf__help__address.country_commands] )) || -_pouf__help__address.country_commands() { - local commands; commands=() - _describe -t commands 'pouf help address.country commands' commands "$@" -} (( $+functions[_pouf__address.street_commands] )) || _pouf__address.street_commands() { local commands; commands=() _describe -t commands 'pouf address.street commands' commands "$@" } -(( $+functions[_pouf__help__address.street_commands] )) || -_pouf__help__address.street_commands() { - local commands; commands=() - _describe -t commands 'pouf help address.street commands' commands "$@" -} (( $+functions[_pouf__administrative.healthinsurrancecode_commands] )) || _pouf__administrative.healthinsurrancecode_commands() { local commands; commands=() _describe -t commands 'pouf administrative.healthinsurrancecode commands' commands "$@" } -(( $+functions[_pouf__help__administrative.healthinsurrancecode_commands] )) || -_pouf__help__administrative.healthinsurrancecode_commands() { - local commands; commands=() - _describe -t commands 'pouf help administrative.healthinsurrancecode commands' commands "$@" -} (( $+functions[_pouf__auto.licenseplate_commands] )) || _pouf__auto.licenseplate_commands() { local commands; commands=() _describe -t commands 'pouf auto.licenseplate commands' commands "$@" } -(( $+functions[_pouf__help__auto.licenseplate_commands] )) || -_pouf__help__auto.licenseplate_commands() { - local commands; commands=() - _describe -t commands 'pouf help auto.licenseplate commands' commands "$@" -} (( $+functions[_pouf__barcode.isbn_commands] )) || _pouf__barcode.isbn_commands() { local commands; commands=() _describe -t commands 'pouf barcode.isbn commands' commands "$@" } -(( $+functions[_pouf__help__barcode.isbn_commands] )) || -_pouf__help__barcode.isbn_commands() { - local commands; commands=() - _describe -t commands 'pouf help barcode.isbn commands' commands "$@" -} (( $+functions[_pouf__color_commands] )) || _pouf__color_commands() { local commands; commands=() _describe -t commands 'pouf color commands' commands "$@" } -(( $+functions[_pouf__help__color_commands] )) || -_pouf__help__color_commands() { - local commands; commands=() - _describe -t commands 'pouf help color commands' commands "$@" -} (( $+functions[_pouf__filesystem.mimetype_commands] )) || _pouf__filesystem.mimetype_commands() { local commands; commands=() _describe -t commands 'pouf filesystem.mimetype commands' commands "$@" } -(( $+functions[_pouf__help__filesystem.mimetype_commands] )) || -_pouf__help__filesystem.mimetype_commands() { - local commands; commands=() - _describe -t commands 'pouf help filesystem.mimetype commands' commands "$@" -} (( $+functions[_pouf__filesystem.semver_commands] )) || _pouf__filesystem.semver_commands() { local commands; commands=() _describe -t commands 'pouf filesystem.semver commands' commands "$@" } -(( $+functions[_pouf__help__filesystem.semver_commands] )) || -_pouf__help__filesystem.semver_commands() { - local commands; commands=() - _describe -t commands 'pouf help filesystem.semver commands' commands "$@" -} (( $+functions[_pouf__finance.bic_commands] )) || _pouf__finance.bic_commands() { local commands; commands=() _describe -t commands 'pouf finance.bic commands' commands "$@" } -(( $+functions[_pouf__help__finance.bic_commands] )) || -_pouf__help__finance.bic_commands() { - local commands; commands=() - _describe -t commands 'pouf help finance.bic commands' commands "$@" -} (( $+functions[_pouf__help_commands] )) || _pouf__help_commands() { local commands; commands=( @@ -479,6 +429,56 @@ _pouf__help_commands() { ) _describe -t commands 'pouf help commands' commands "$@" } +(( $+functions[_pouf__help__address.city_commands] )) || +_pouf__help__address.city_commands() { + local commands; commands=() + _describe -t commands 'pouf help address.city commands' commands "$@" +} +(( $+functions[_pouf__help__address.country_commands] )) || +_pouf__help__address.country_commands() { + local commands; commands=() + _describe -t commands 'pouf help address.country commands' commands "$@" +} +(( $+functions[_pouf__help__address.street_commands] )) || +_pouf__help__address.street_commands() { + local commands; commands=() + _describe -t commands 'pouf help address.street commands' commands "$@" +} +(( $+functions[_pouf__help__administrative.healthinsurrancecode_commands] )) || +_pouf__help__administrative.healthinsurrancecode_commands() { + local commands; commands=() + _describe -t commands 'pouf help administrative.healthinsurrancecode commands' commands "$@" +} +(( $+functions[_pouf__help__auto.licenseplate_commands] )) || +_pouf__help__auto.licenseplate_commands() { + local commands; commands=() + _describe -t commands 'pouf help auto.licenseplate commands' commands "$@" +} +(( $+functions[_pouf__help__barcode.isbn_commands] )) || +_pouf__help__barcode.isbn_commands() { + local commands; commands=() + _describe -t commands 'pouf help barcode.isbn commands' commands "$@" +} +(( $+functions[_pouf__help__color_commands] )) || +_pouf__help__color_commands() { + local commands; commands=() + _describe -t commands 'pouf help color commands' commands "$@" +} +(( $+functions[_pouf__help__filesystem.mimetype_commands] )) || +_pouf__help__filesystem.mimetype_commands() { + local commands; commands=() + _describe -t commands 'pouf help filesystem.mimetype commands' commands "$@" +} +(( $+functions[_pouf__help__filesystem.semver_commands] )) || +_pouf__help__filesystem.semver_commands() { + local commands; commands=() + _describe -t commands 'pouf help filesystem.semver commands' commands "$@" +} +(( $+functions[_pouf__help__finance.bic_commands] )) || +_pouf__help__finance.bic_commands() { + local commands; commands=() + _describe -t commands 'pouf help finance.bic commands' commands "$@" +} (( $+functions[_pouf__help__help_commands] )) || _pouf__help__help_commands() { local commands; commands=() @@ -489,96 +489,96 @@ _pouf__help__http.code_commands() { local commands; commands=() _describe -t commands 'pouf help http.code commands' commands "$@" } -(( $+functions[_pouf__http.code_commands] )) || -_pouf__http.code_commands() { - local commands; commands=() - _describe -t commands 'pouf http.code commands' commands "$@" -} (( $+functions[_pouf__help__internet.ip_commands] )) || _pouf__help__internet.ip_commands() { local commands; commands=() _describe -t commands 'pouf help internet.ip commands' commands "$@" } -(( $+functions[_pouf__internet.ip_commands] )) || -_pouf__internet.ip_commands() { - local commands; commands=() - _describe -t commands 'pouf internet.ip commands' commands "$@" -} (( $+functions[_pouf__help__internet.mac_commands] )) || _pouf__help__internet.mac_commands() { local commands; commands=() _describe -t commands 'pouf help internet.mac commands' commands "$@" } -(( $+functions[_pouf__internet.mac_commands] )) || -_pouf__internet.mac_commands() { - local commands; commands=() - _describe -t commands 'pouf internet.mac commands' commands "$@" -} (( $+functions[_pouf__help__internet.mail_commands] )) || _pouf__help__internet.mail_commands() { local commands; commands=() _describe -t commands 'pouf help internet.mail commands' commands "$@" } -(( $+functions[_pouf__internet.mail_commands] )) || -_pouf__internet.mail_commands() { - local commands; commands=() - _describe -t commands 'pouf internet.mail commands' commands "$@" -} (( $+functions[_pouf__help__internet.useragent_commands] )) || _pouf__help__internet.useragent_commands() { local commands; commands=() _describe -t commands 'pouf help internet.useragent commands' commands "$@" } -(( $+functions[_pouf__internet.useragent_commands] )) || -_pouf__internet.useragent_commands() { - local commands; commands=() - _describe -t commands 'pouf internet.useragent commands' commands "$@" -} (( $+functions[_pouf__help__lorem.word_commands] )) || _pouf__help__lorem.word_commands() { local commands; commands=() _describe -t commands 'pouf help lorem.word commands' commands "$@" } -(( $+functions[_pouf__lorem.word_commands] )) || -_pouf__lorem.word_commands() { - local commands; commands=() - _describe -t commands 'pouf lorem.word commands' commands "$@" -} (( $+functions[_pouf__help__people.name_commands] )) || _pouf__help__people.name_commands() { local commands; commands=() _describe -t commands 'pouf help people.name commands' commands "$@" } -(( $+functions[_pouf__people.name_commands] )) || -_pouf__people.name_commands() { - local commands; commands=() - _describe -t commands 'pouf people.name commands' commands "$@" -} (( $+functions[_pouf__help__template_commands] )) || _pouf__help__template_commands() { local commands; commands=() _describe -t commands 'pouf help template commands' commands "$@" } -(( $+functions[_pouf__template_commands] )) || -_pouf__template_commands() { - local commands; commands=() - _describe -t commands 'pouf template commands' commands "$@" -} (( $+functions[_pouf__help__time.date_commands] )) || _pouf__help__time.date_commands() { local commands; commands=() _describe -t commands 'pouf help time.date commands' commands "$@" } -(( $+functions[_pouf__time.date_commands] )) || -_pouf__time.date_commands() { - local commands; commands=() - _describe -t commands 'pouf time.date commands' commands "$@" -} (( $+functions[_pouf__help__time.time_commands] )) || _pouf__help__time.time_commands() { local commands; commands=() _describe -t commands 'pouf help time.time commands' commands "$@" } +(( $+functions[_pouf__http.code_commands] )) || +_pouf__http.code_commands() { + local commands; commands=() + _describe -t commands 'pouf http.code commands' commands "$@" +} +(( $+functions[_pouf__internet.ip_commands] )) || +_pouf__internet.ip_commands() { + local commands; commands=() + _describe -t commands 'pouf internet.ip commands' commands "$@" +} +(( $+functions[_pouf__internet.mac_commands] )) || +_pouf__internet.mac_commands() { + local commands; commands=() + _describe -t commands 'pouf internet.mac commands' commands "$@" +} +(( $+functions[_pouf__internet.mail_commands] )) || +_pouf__internet.mail_commands() { + local commands; commands=() + _describe -t commands 'pouf internet.mail commands' commands "$@" +} +(( $+functions[_pouf__internet.useragent_commands] )) || +_pouf__internet.useragent_commands() { + local commands; commands=() + _describe -t commands 'pouf internet.useragent commands' commands "$@" +} +(( $+functions[_pouf__lorem.word_commands] )) || +_pouf__lorem.word_commands() { + local commands; commands=() + _describe -t commands 'pouf lorem.word commands' commands "$@" +} +(( $+functions[_pouf__people.name_commands] )) || +_pouf__people.name_commands() { + local commands; commands=() + _describe -t commands 'pouf people.name commands' commands "$@" +} +(( $+functions[_pouf__template_commands] )) || +_pouf__template_commands() { + local commands; commands=() + _describe -t commands 'pouf template commands' commands "$@" +} +(( $+functions[_pouf__time.date_commands] )) || +_pouf__time.date_commands() { + local commands; commands=() + _describe -t commands 'pouf time.date commands' commands "$@" +} (( $+functions[_pouf__time.time_commands] )) || _pouf__time.time_commands() { local commands; commands=() diff --git a/examples/templates/color.css b/examples/templates/color.css index e35a3fc..9f0f2fa 100644 --- a/examples/templates/color.css +++ b/examples/templates/color.css @@ -1,5 +1,3 @@ -{% set colors_nb = 3 %} - :root { --main-bg: {{ colors.0.hex }}; --main-color: {{ colors.0.rgb }}; diff --git a/examples/templates/isbn.txt b/examples/templates/isbn.txt index e3dff81..ff89a69 100644 --- a/examples/templates/isbn.txt +++ b/examples/templates/isbn.txt @@ -1,8 +1,5 @@ -{% set barecodes_nb = 2 %} - -{% for barecode in barecodes %} +{% for barecode in barecodes(2) %} {{ barecode.isbn }} {{ barecode.isbn10 }} {{ barecode.isbn13 }} - -{% endfor %} +{% endfor %} \ No newline at end of file diff --git a/examples/templates/lorem.html b/examples/templates/lorem.html index 9ea2611..f30b7b0 100644 --- a/examples/templates/lorem.html +++ b/examples/templates/lorem.html @@ -1,18 +1,13 @@ -{% set lorems_nb = 3 %} -{% set lorems_words_nb = 9 %} -{% set lorems_sentences_nb = 4 %} -{% set lorems_paragraphs_nb = 2 %} - - {% for lorem in lorems %} + {% for lorem in lorems(3) %} - {% for word in lorem.words %}{{ word }} {% endfor %} + {% for word in lorem.words(9) %}{{ word }} {% endfor %}

- {% for sentence in lorem.sentences %}{{ sentence }}
{% endfor %} + {% for sentence in lorem.sentences(4) %}{{ sentence }}
{% endfor %}

- {% for paragraph in lorem.paragraphs %} + {% for paragraph in lorem.paragraphs(2) %}

{{ paragraph }}

{% endfor %}
diff --git a/examples/templates/misc.txt b/examples/templates/misc.txt index cb92be8..d0deeb2 100644 --- a/examples/templates/misc.txt +++ b/examples/templates/misc.txt @@ -1,10 +1,8 @@ -{% set autos_nb = 3 %} -{% for auto in autos %} - {{ auto.licence_plate }} +{% for automotive in autos(2) %} + {{ automotive.licence_plate }} {% endfor %} -{% set internets_nb = 2 %} -{% for internet in internets %} +{% for internet in internets(3) %} {{ internet.free_email_provider }} {{ internet.domain_suffix }} {{ internet.free_email }} @@ -18,14 +16,12 @@ {{ internet.useragent }} {% endfor %} -{% set phones_nb = 4 %} -{% for phone in phones %} +{% for phone in phones(4) %} {{ phone.fix }} {{ phone.cell }} {% endfor %} -{% set filesystems_nb = 2 %} -{% for filesystem in filesystems %} +{% for filesystem in filesystems(2) %} {{ filesystem.dir_path }} {{ filesystem.file_extension }} {{ filesystem.file_name }} @@ -34,24 +30,14 @@ {{ filesystem.semver }} {% endfor %} -{% set jobs_nb = 2 %} -{% for job in jobs %} +{% for job in jobs(2) %} {{ job.seniority }} {{ job.field }} {{ job.position }} {{ job.title }} {% endfor %} -{% set currencies_nb = 2 %} - -{{ currencies.0.code }} -{{ currencies.1.code }} - -{{ currencies.0.name }} -{{ currencies.0.symbol }} - -{% set http_codes_nb = 3 %} -{% for http in http_codes %} +{% for http in http_codes(3) %} {{ http.rfc_status_code }} {{ http.valid_status_code }} {% endfor %} diff --git a/examples/templates/people.json b/examples/templates/people.json index 781e66d..895fe62 100644 --- a/examples/templates/people.json +++ b/examples/templates/people.json @@ -1,37 +1,67 @@ -{% set peoples_nb = 2 %} -{% set lang = "fr" %} - { "results": [ - {% for people in peoples %} + {% for people in peoples(5) %} { + "color": { + "hex": "{{ color.hex }}", + "rgb": "{{ color.rgb }}", + "rgba": "{{ color.rgba }}", + "hsl": "{{ color.hsl }}", + "hsla": "{{ color.hsla }}" + }, + "barecode": { + "isbn": "{{ barecode.isbn }}", + "isbn10": "{{ barecode.isbn10 }}", + "isbn13": "{{ barecode.isbn13 }}" + }, + "currency": { + "code": "{{ currency.code }}", + "name": "{{ currency.name }}", + "symbol": "{{ currency.symbol }}" + }, + "semver": "{{ filesystem.semver }}", + "http_rfc_code": "{{ http.rfc_status_code }}", + "http_valid_code": "{{ http.valid_status_code }}", "gender": "{{ people.gender }}", "birthday": "{{ people.birthday }}", - "phone": "{{ phone.fix }}", - "cell": "{{ phone.cell }}", + "phone": "{{ people.phone.fix }}", + "cell": "{{ people.phone.cell }}", "name": { "title": "{{ people.title }}", "first": "{{ people.first_name }}", "last": "{{ people.last_name }}" }, + "internet": { + "free_email_provider": "{{ internet.free_email_provider }}", + "domain_suffix": "{{ internet.domain_suffix }}", + "free_email": "{{ internet.free_email }}", + "safe_email": "{{ internet.safe_email }}", + "username": "{{ internet.username }}", + "password": "{{ internet.password }}", + "ip": "{{ internet.ip }}", + "ipv4": "{{ internet.ipv4 }}", + "ipv6": "{{ internet.ipv6 }}", + "mac_address": "{{ internet.mac_address }}", + "useragent": "{{ internet.useragent }}" + }, "job": { "seniority": "{{ people.job.seniority }}", "field": "{{ people.job.field }}", "position": "{{ people.job.position }}", "title": "{{ people.job.title }}" - } + }, "location": { - "city": "{{ people.location.city }}", - "state": "{{ people.location.city }}", - "country": "{{ people.location.country }}", - "zipcode": "{{ people.location.zipcode }}", + "city": "{{ people.address.city }}", + "state": "{{ people.address.city }}", + "country": "{{ people.address.country }}", + "zipcode": "{{ people.address.zipcode }}", "coordinates": { - "latitude": "{{ people.location.coordinates.latitude }}", - "longitude": "{{ people.location.coordinates.longitude }}", - "geohash": "{{ people.location.coordinates.geohash }}", + "latitude": "{{ people.address.coordinates.latitude }}", + "longitude": "{{ people.address.coordinates.longitude }}", + "geohash": "{{ people.address.coordinates.geohash }}", }, "timezone": { - "description": "{{ people.location.timezone.description }}", + "description": "{{ people.address.timezone.description }}", } }, "automotive": { @@ -39,5 +69,5 @@ } } {% endfor %} - ], + ] } diff --git a/pouf.bash b/pouf.bash index 2aac435..5e82140 100644 --- a/pouf.bash +++ b/pouf.bash @@ -933,4 +933,8 @@ _pouf() { esac } -complete -F _pouf -o nosort -o bashdefault -o default pouf +if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then + complete -F _pouf -o nosort -o bashdefault -o default pouf +else + complete -F _pouf -o bashdefault -o default pouf +fi diff --git a/pouf.fish b/pouf.fish index 2db9dc4..86808e8 100644 --- a/pouf.fish +++ b/pouf.fish @@ -1,100 +1,126 @@ -complete -c pouf -n "__fish_use_subcommand" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_use_subcommand" -s V -l version -d 'Print version' -complete -c pouf -n "__fish_use_subcommand" -f -a "template" -d 'generate file with template' -complete -c pouf -n "__fish_use_subcommand" -f -a "address.city" -d 'give a city name (English only)' -complete -c pouf -n "__fish_use_subcommand" -f -a "address.country" -d 'give a country name and code (English only)' -complete -c pouf -n "__fish_use_subcommand" -f -a "address.street" -d 'give a street name (English only)' -complete -c pouf -n "__fish_use_subcommand" -f -a "administrative.healthinsurrancecode" -d 'give a Health insurrance code (French only)' -complete -c pouf -n "__fish_use_subcommand" -f -a "auto.licenseplate" -d 'give an automotive license plate (French only)' -complete -c pouf -n "__fish_use_subcommand" -f -a "barcode.isbn" -d 'give an isbn code' -complete -c pouf -n "__fish_use_subcommand" -f -a "color" -d 'give a fake color (hexadécimal, rgb, rgba, hsl and hsla representation)' -complete -c pouf -n "__fish_use_subcommand" -f -a "filesystem.mimetype" -d 'give a fake mime-type' -complete -c pouf -n "__fish_use_subcommand" -f -a "filesystem.semver" -d 'give a fake semver version' -complete -c pouf -n "__fish_use_subcommand" -f -a "finance.bic" -d 'give a fake BIC (Business Identifier Code)' -complete -c pouf -n "__fish_use_subcommand" -f -a "http.code" -d 'give a fake HTTP code' -complete -c pouf -n "__fish_use_subcommand" -f -a "internet.ip" -d 'give a fake IP (Internet Protocol)' -complete -c pouf -n "__fish_use_subcommand" -f -a "internet.mac" -d 'give a fake mac adress' -complete -c pouf -n "__fish_use_subcommand" -f -a "internet.mail" -d 'give a fake mail' -complete -c pouf -n "__fish_use_subcommand" -f -a "internet.useragent" -d 'give a fake user agent' -complete -c pouf -n "__fish_use_subcommand" -f -a "lorem.word" -d 'give a fake word (in Latin)' -complete -c pouf -n "__fish_use_subcommand" -f -a "people.name" -d 'give a fake name' -complete -c pouf -n "__fish_use_subcommand" -f -a "time.time" -d 'give a fake time' -complete -c pouf -n "__fish_use_subcommand" -f -a "time.date" -d 'give a fake date' -complete -c pouf -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' -complete -c pouf -n "__fish_seen_subcommand_from template" -s i -l input -d 'give an input template file (tera : https://tera.netlify.app/)' -r -F -complete -c pouf -n "__fish_seen_subcommand_from template" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from template" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from address.city" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from address.city" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from address.country" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from address.country" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from address.street" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from address.street" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from administrative.healthinsurrancecode" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from administrative.healthinsurrancecode" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from auto.licenseplate" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from auto.licenseplate" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from barcode.isbn" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from barcode.isbn" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from color" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from color" -s d -l hexa -d 'give a fake hexadecimal color' -complete -c pouf -n "__fish_seen_subcommand_from color" -s r -l rgb -d 'give a fake rgb color' -complete -c pouf -n "__fish_seen_subcommand_from color" -s a -l rgba -d 'give a fake rgba color' -complete -c pouf -n "__fish_seen_subcommand_from color" -s t -l hsl -d 'give a fake hsl (tsl) color' -complete -c pouf -n "__fish_seen_subcommand_from color" -s l -l hsla -d 'give a fake hsla (tsl) color' -complete -c pouf -n "__fish_seen_subcommand_from color" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from filesystem.mimetype" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from filesystem.mimetype" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from filesystem.semver" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from filesystem.semver" -s s -l stable -d 'give exclusivly stable semver version (X.Y.Z)' -complete -c pouf -n "__fish_seen_subcommand_from filesystem.semver" -s u -l unstable -d 'give exclusivly unstable semver version (X-Y-Z-V.W)' -complete -c pouf -n "__fish_seen_subcommand_from filesystem.semver" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from finance.bic" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from finance.bic" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from http.code" -s l -l lang -d 'give lang (ie: fr_FR)' -r -f -a "{fr '',fr_FR '',en ''}" -complete -c pouf -n "__fish_seen_subcommand_from http.code" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from http.code" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from internet.ip" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from internet.ip" -s 4 -l ipv4 -d 'give exclusivly IPv4' -complete -c pouf -n "__fish_seen_subcommand_from internet.ip" -s 6 -l ipv6 -d 'give exclusivly IPv6' -complete -c pouf -n "__fish_seen_subcommand_from internet.ip" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from internet.mac" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from internet.mac" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from internet.mail" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from internet.mail" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from internet.useragent" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from internet.useragent" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from lorem.word" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from lorem.word" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from people.name" -s l -l lang -d 'give lang (ie: fr_FR)' -r -f -a "{fr '',fr_FR '',en ''}" -complete -c pouf -n "__fish_seen_subcommand_from people.name" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from people.name" -s t -l title -d 'give a fake name title' -complete -c pouf -n "__fish_seen_subcommand_from people.name" -s w -l with-title -d 'give a fake name with her title' -complete -c pouf -n "__fish_seen_subcommand_from people.name" -s f -l firstname -d 'give a fake firstname' -complete -c pouf -n "__fish_seen_subcommand_from people.name" -s z -l lastname -d 'give a fake lastname' -complete -c pouf -n "__fish_seen_subcommand_from people.name" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from time.time" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from time.time" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from time.date" -s n -l number -d 'number of values' -r -complete -c pouf -n "__fish_seen_subcommand_from time.date" -s h -l help -d 'Print help' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "template" -d 'generate file with template' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "address.city" -d 'give a city name (English only)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "address.country" -d 'give a country name and code (English only)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "address.street" -d 'give a street name (English only)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "administrative.healthinsurrancecode" -d 'give a Health insurrance code (French only)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "auto.licenseplate" -d 'give an automotive license plate (French only)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "barcode.isbn" -d 'give an isbn code' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "color" -d 'give a fake color (hexadécimal, rgb, rgba, hsl and hsla representation)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "filesystem.mimetype" -d 'give a fake mime-type' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "filesystem.semver" -d 'give a fake semver version' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "finance.bic" -d 'give a fake BIC (Business Identifier Code)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "http.code" -d 'give a fake HTTP code' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "internet.ip" -d 'give a fake IP (Internet Protocol)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "internet.mac" -d 'give a fake mac adress' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "internet.mail" -d 'give a fake mail' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "internet.useragent" -d 'give a fake user agent' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "lorem.word" -d 'give a fake word (in Latin)' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "people.name" -d 'give a fake name' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "time.time" -d 'give a fake time' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "time.date" -d 'give a fake date' -complete -c pouf -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from template; and not __fish_seen_subcommand_from address.city; and not __fish_seen_subcommand_from address.country; and not __fish_seen_subcommand_from address.street; and not __fish_seen_subcommand_from administrative.healthinsurrancecode; and not __fish_seen_subcommand_from auto.licenseplate; and not __fish_seen_subcommand_from barcode.isbn; and not __fish_seen_subcommand_from color; and not __fish_seen_subcommand_from filesystem.mimetype; and not __fish_seen_subcommand_from filesystem.semver; and not __fish_seen_subcommand_from finance.bic; and not __fish_seen_subcommand_from http.code; and not __fish_seen_subcommand_from internet.ip; and not __fish_seen_subcommand_from internet.mac; and not __fish_seen_subcommand_from internet.mail; and not __fish_seen_subcommand_from internet.useragent; and not __fish_seen_subcommand_from lorem.word; and not __fish_seen_subcommand_from people.name; and not __fish_seen_subcommand_from time.time; and not __fish_seen_subcommand_from time.date; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' +# Print an optspec for argparse to handle cmd's options that are independent of any subcommand. +function __fish_pouf_global_optspecs + string join \n h/help V/version +end + +function __fish_pouf_needs_command + # Figure out if the current invocation already has a command. + set -l cmd (commandline -opc) + set -e cmd[1] + argparse -s (__fish_pouf_global_optspecs) -- $cmd 2>/dev/null + or return + if set -q argv[1] + # Also print the command, so this can be used to figure out what it is. + echo $argv[1] + return 1 + end + return 0 +end + +function __fish_pouf_using_subcommand + set -l cmd (__fish_pouf_needs_command) + test -z "$cmd" + and return 1 + contains -- $cmd[1] $argv +end + +complete -c pouf -n "__fish_pouf_needs_command" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_needs_command" -s V -l version -d 'Print version' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "template" -d 'generate file with template' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "address.city" -d 'give a city name (English only)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "address.country" -d 'give a country name and code (English only)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "address.street" -d 'give a street name (English only)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "administrative.healthinsurrancecode" -d 'give a Health insurrance code (French only)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "auto.licenseplate" -d 'give an automotive license plate (French only)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "barcode.isbn" -d 'give an isbn code' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "color" -d 'give a fake color (hexadécimal, rgb, rgba, hsl and hsla representation)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "filesystem.mimetype" -d 'give a fake mime-type' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "filesystem.semver" -d 'give a fake semver version' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "finance.bic" -d 'give a fake BIC (Business Identifier Code)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "http.code" -d 'give a fake HTTP code' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "internet.ip" -d 'give a fake IP (Internet Protocol)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "internet.mac" -d 'give a fake mac adress' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "internet.mail" -d 'give a fake mail' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "internet.useragent" -d 'give a fake user agent' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "lorem.word" -d 'give a fake word (in Latin)' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "people.name" -d 'give a fake name' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "time.time" -d 'give a fake time' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "time.date" -d 'give a fake date' +complete -c pouf -n "__fish_pouf_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' +complete -c pouf -n "__fish_pouf_using_subcommand template" -s i -l input -d 'give an input template file (tera : https://tera.netlify.app/)' -r -F +complete -c pouf -n "__fish_pouf_using_subcommand template" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand template" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand address.city" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand address.city" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand address.country" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand address.country" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand address.street" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand address.street" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand administrative.healthinsurrancecode" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand administrative.healthinsurrancecode" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand auto.licenseplate" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand auto.licenseplate" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand barcode.isbn" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand barcode.isbn" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand color" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand color" -s d -l hexa -d 'give a fake hexadecimal color' +complete -c pouf -n "__fish_pouf_using_subcommand color" -s r -l rgb -d 'give a fake rgb color' +complete -c pouf -n "__fish_pouf_using_subcommand color" -s a -l rgba -d 'give a fake rgba color' +complete -c pouf -n "__fish_pouf_using_subcommand color" -s t -l hsl -d 'give a fake hsl (tsl) color' +complete -c pouf -n "__fish_pouf_using_subcommand color" -s l -l hsla -d 'give a fake hsla (tsl) color' +complete -c pouf -n "__fish_pouf_using_subcommand color" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand filesystem.mimetype" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand filesystem.mimetype" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand filesystem.semver" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand filesystem.semver" -s s -l stable -d 'give exclusivly stable semver version (X.Y.Z)' +complete -c pouf -n "__fish_pouf_using_subcommand filesystem.semver" -s u -l unstable -d 'give exclusivly unstable semver version (X-Y-Z-V.W)' +complete -c pouf -n "__fish_pouf_using_subcommand filesystem.semver" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand finance.bic" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand finance.bic" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand http.code" -s l -l lang -d 'give lang (ie: fr_FR)' -r -f -a "{fr\t'',fr_FR\t'',en\t''}" +complete -c pouf -n "__fish_pouf_using_subcommand http.code" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand http.code" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand internet.ip" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand internet.ip" -s 4 -l ipv4 -d 'give exclusivly IPv4' +complete -c pouf -n "__fish_pouf_using_subcommand internet.ip" -s 6 -l ipv6 -d 'give exclusivly IPv6' +complete -c pouf -n "__fish_pouf_using_subcommand internet.ip" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand internet.mac" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand internet.mac" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand internet.mail" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand internet.mail" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand internet.useragent" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand internet.useragent" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand lorem.word" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand lorem.word" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand people.name" -s l -l lang -d 'give lang (ie: fr_FR)' -r -f -a "{fr\t'',fr_FR\t'',en\t''}" +complete -c pouf -n "__fish_pouf_using_subcommand people.name" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand people.name" -s t -l title -d 'give a fake name title' +complete -c pouf -n "__fish_pouf_using_subcommand people.name" -s w -l with-title -d 'give a fake name with her title' +complete -c pouf -n "__fish_pouf_using_subcommand people.name" -s f -l firstname -d 'give a fake firstname' +complete -c pouf -n "__fish_pouf_using_subcommand people.name" -s z -l lastname -d 'give a fake lastname' +complete -c pouf -n "__fish_pouf_using_subcommand people.name" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand time.time" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand time.time" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand time.date" -s n -l number -d 'number of values' -r +complete -c pouf -n "__fish_pouf_using_subcommand time.date" -s h -l help -d 'Print help' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "template" -d 'generate file with template' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "address.city" -d 'give a city name (English only)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "address.country" -d 'give a country name and code (English only)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "address.street" -d 'give a street name (English only)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "administrative.healthinsurrancecode" -d 'give a Health insurrance code (French only)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "auto.licenseplate" -d 'give an automotive license plate (French only)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "barcode.isbn" -d 'give an isbn code' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "color" -d 'give a fake color (hexadécimal, rgb, rgba, hsl and hsla representation)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "filesystem.mimetype" -d 'give a fake mime-type' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "filesystem.semver" -d 'give a fake semver version' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "finance.bic" -d 'give a fake BIC (Business Identifier Code)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "http.code" -d 'give a fake HTTP code' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "internet.ip" -d 'give a fake IP (Internet Protocol)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "internet.mac" -d 'give a fake mac adress' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "internet.mail" -d 'give a fake mail' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "internet.useragent" -d 'give a fake user agent' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "lorem.word" -d 'give a fake word (in Latin)' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "people.name" -d 'give a fake name' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "time.time" -d 'give a fake time' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "time.date" -d 'give a fake date' +complete -c pouf -n "__fish_pouf_using_subcommand help; and not __fish_seen_subcommand_from template address.city address.country address.street administrative.healthinsurrancecode auto.licenseplate barcode.isbn color filesystem.mimetype filesystem.semver finance.bic http.code internet.ip internet.mac internet.mail internet.useragent lorem.word people.name time.time time.date help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' diff --git a/src/domain/address.rs b/src/domain/address.rs index 93b7066..6c09964 100644 --- a/src/domain/address.rs +++ b/src/domain/address.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(l) = matches.subcommand_matches("address.country") { use fake::faker::address::raw::CountryName; diff --git a/src/domain/administrative.rs b/src/domain/administrative.rs index ef0faca..d3ed132 100644 --- a/src/domain/administrative.rs +++ b/src/domain/administrative.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(l) = matches.subcommand_matches("administrative.healthinsurrancecode") { use fake::faker::administrative::raw::HealthInsuranceCode; diff --git a/src/domain/auto.rs b/src/domain/auto.rs index be67429..8e9c142 100644 --- a/src/domain/auto.rs +++ b/src/domain/auto.rs @@ -2,6 +2,8 @@ use clap::ArgMatches; use fake::locales::FR_FR; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(l) = matches.subcommand_matches("auto.licenseplate") { use fake::faker::automotive::raw::LicencePlate; diff --git a/src/domain/barcode.rs b/src/domain/barcode.rs index 2af18a4..4de7a4b 100644 --- a/src/domain/barcode.rs +++ b/src/domain/barcode.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(isbn) = matches.subcommand_matches("barcode.isbn") { use fake::faker::barcode::raw::Isbn13; diff --git a/src/domain/filesystem.rs b/src/domain/filesystem.rs index 55c09ab..899d087 100644 --- a/src/domain/filesystem.rs +++ b/src/domain/filesystem.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(mimetype) = matches.subcommand_matches("filesystem.mimetype") { use fake::faker::filesystem::raw::MimeType; diff --git a/src/domain/finance.rs b/src/domain/finance.rs index bc0081c..12731d8 100644 --- a/src/domain/finance.rs +++ b/src/domain/finance.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(bic) = matches.subcommand_matches("finance.bic") { use fake::faker::finance::raw::Bic; diff --git a/src/domain/http.rs b/src/domain/http.rs index 34e2c46..db36ade 100644 --- a/src/domain/http.rs +++ b/src/domain/http.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(code) = matches.subcommand_matches("http.code") { use fake::faker::http::raw::RfcStatusCode; diff --git a/src/domain/internet.rs b/src/domain/internet.rs index 145af45..b73ec3a 100644 --- a/src/domain/internet.rs +++ b/src/domain/internet.rs @@ -3,6 +3,8 @@ use fake::locales::Data; use fake::{Dummy, Fake}; use rand::Rng; +use pouf::lang_env; + struct UnidecodeFreeEmail(L); impl Dummy> for String { diff --git a/src/domain/lorem.rs b/src/domain/lorem.rs index 23dd645..5634b90 100644 --- a/src/domain/lorem.rs +++ b/src/domain/lorem.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(w) = matches.subcommand_matches("lorem.word") { use fake::faker::lorem::raw::Word; diff --git a/src/domain/mod.rs b/src/domain/mod.rs index e4f5d37..57e5ce7 100644 --- a/src/domain/mod.rs +++ b/src/domain/mod.rs @@ -9,4 +9,4 @@ pub mod http; pub mod internet; pub mod lorem; pub mod people; -pub mod time; +pub mod time; \ No newline at end of file diff --git a/src/domain/people.rs b/src/domain/people.rs index 7dd7db4..f8f25cc 100644 --- a/src/domain/people.rs +++ b/src/domain/people.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(name) = matches.subcommand_matches("people.name") { use fake::faker::name::raw::{FirstName, LastName, Name, NameWithTitle, Title}; diff --git a/src/domain/time.rs b/src/domain/time.rs index f3574a0..5d2662c 100644 --- a/src/domain/time.rs +++ b/src/domain/time.rs @@ -1,6 +1,8 @@ use clap::ArgMatches; use fake::Fake; +use pouf::lang_env; + pub fn run(matches: &ArgMatches) { if let Some(date) = matches.subcommand_matches("time.date") { use fake::faker::chrono::raw::DateTime; diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..b2534ef --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,10 @@ +#[macro_use] +pub mod macros; +pub mod template; + +pub fn lang_env() -> Option { + match std::env::var("LANG") { + Ok(_l) => _l.find('.').map(|pos| _l[0..pos].to_lowercase()), + Err(_) => None, + } +} diff --git a/src/macros.rs b/src/macros.rs index f7a6fe2..b6c2eae 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -42,7 +42,6 @@ macro_rules! lang_return { macro_rules! lang_struct { ($struct_name:ident) => { - use crate::lang_env; match lang_env() { Some(lang) => { lang_struct!($struct_name, &*lang); @@ -103,7 +102,6 @@ macro_rules! each { macro_rules! force_lang_struct { ($struct_name:ident, $force_lang:ident, $has_user_lang:expr) => { - use crate::lang_env; use clap::error::ErrorKind; use clap::{Command, Error}; @@ -221,3 +219,21 @@ macro_rules! force_each { } }; } + +macro_rules! create_get_property { + ($struct_name:ident, $( $field_name:ident : $field_type:ty ),* ) => { + use std::any::Any; + use crate::template::template_trait::TemplateObject; + + impl TemplateObject for $struct_name { + fn get_property(&self, key: &str) -> Option<&dyn Any> { + match key { + $( + stringify!($field_name) => Some(&self.$field_name as &dyn Any), + )* + _ => None, + } + } + } + } +} diff --git a/src/main.rs b/src/main.rs index cd93276..0c83f2a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,13 +6,12 @@ extern crate fake; extern crate http; extern crate semver; extern crate serde; -extern crate tera; use std::env; use std::fs; use std::path::PathBuf; -use tera::{Context, Tera}; +use askama_parser::{Ast, Syntax}; mod cli; #[macro_use] @@ -20,226 +19,26 @@ mod macros; mod domain; mod template; -use crate::template::{ - automotive::Automotive, barecode::BareCode, color::Color, currency::Currency, - filesystem::FileSystem, http::Http, internet::Internet, job::Job, lorem::Lorem, parser::parse, - people::People, phone::Phone, -}; - -fn lang_env() -> Option { - match std::env::var("LANG") { - Ok(_l) => _l.find('.').map(|pos| _l[0..pos].to_lowercase()), - Err(_) => None, - } -} +use crate::template::{generator::AstLevel, generator::Generator}; +use pouf::lang_env; fn main() { let matches = cli::build_cli(crate_name!(), crate_version!()).get_matches(); if let Some(template_m) = matches.subcommand_matches("template") { if let Some(input) = template_m.get_one::("input") { - let mut contents = + let contents = fs::read_to_string(input).expect("Should have been able to read the file"); - let nodes = parse(&contents); - - let mut nb_peoples = 0; - let mut nb_lorems = 0; - let mut lorems_words_nb = 0; - let mut lorems_sentences_nb = 0; - let mut lorems_paragraphs_nb = 0; - let mut colors_nb = 0; - let mut barecodes_nb = 0; - let mut autos_nb = 0; - let mut internets_nb = 0; - let mut phones_nb = 0; - let mut filesystems_nb = 0; - let mut jobs_nb = 0; - let mut currencies_nb = 0; - let mut http_codes_nb = 0; - - for n in nodes { - match n.key.as_str() { - "peoples_nb" => { - nb_peoples = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "lorems_nb" => { - nb_lorems = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "lorems_words_nb" => { - lorems_words_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "lorems_sentences_nb" => { - lorems_sentences_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "lorems_paragraphs_nb" => { - lorems_paragraphs_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "colors_nb" => { - colors_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "barecodes_nb" => { - barecodes_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "autos_nb" => { - autos_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "internets_nb" => { - internets_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "phones_nb" => { - phones_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "filesystems_nb" => { - filesystems_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "jobs_nb" => { - jobs_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "currencies_nb" => { - currencies_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "http_codes_nb" => { - http_codes_nb = n.value.parse::().unwrap_or(0); - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - "lang" => { - contents = contents.replace(&format!("{}\n", &n.tag), ""); - } - _ => {} - } - } - - let mut peoples = vec![]; - if nb_peoples > 0 { - for _ in 0..nb_peoples { - peoples.push(People::create(template_m)); - } - } - - let mut lorems = vec![]; - if nb_lorems > 0 { - for _ in 0..nb_lorems { - lorems.push(Lorem::create( - template_m, - lorems_words_nb, - lorems_sentences_nb, - lorems_paragraphs_nb, - )); - } - } - - let mut colors = vec![]; - if colors_nb > 0 { - for _ in 0..colors_nb { - colors.push(Color::create(template_m)); - } - } - - let mut barecodes = vec![]; - if barecodes_nb > 0 { - for _ in 0..barecodes_nb { - barecodes.push(Color::create(template_m)); - } - } - - let mut autos = vec![]; - if autos_nb > 0 { - for _ in 0..autos_nb { - autos.push(Automotive::create(template_m)); - } - } - - let mut internets = vec![]; - if internets_nb > 0 { - for _ in 0..internets_nb { - internets.push(Internet::create(template_m)); - } - } - - let mut phones = vec![]; - if phones_nb > 0 { - for _ in 0..phones_nb { - phones.push(Phone::create(template_m)); - } - } - - let mut filesystems = vec![]; - if filesystems_nb > 0 { - for _ in 0..filesystems_nb { - filesystems.push(FileSystem::create(template_m)); - } - } - - let mut jobs = vec![]; - if jobs_nb > 0 { - for _ in 0..jobs_nb { - jobs.push(Job::create(template_m)); - } - } + let ast = Ast::from_str(&contents, &Syntax::default()).unwrap(); - let mut currencies = vec![]; - if currencies_nb > 0 { - for _ in 0..jobs_nb { - currencies.push(Currency::create(template_m)); - } - } + let mut g = Generator::new(template_m); - let mut http_codes = vec![]; - if http_codes_nb > 0 { - for _ in 0..http_codes_nb { - http_codes.push(Http::create(template_m)); - } + if let Err(err) = g.handle(ast.nodes(), AstLevel::Top) { + eprint!("{}", err); + return; } - - let mut context = Context::new(); - context.insert("peoples", &peoples); - context.insert("people", &People::create(template_m)); - context.insert("lorems", &lorems); - context.insert( - "lorem", - &Lorem::create( - template_m, - lorems_words_nb, - lorems_sentences_nb, - lorems_paragraphs_nb, - ), - ); - context.insert("colors", &colors); - context.insert("color", &Color::create(template_m)); - context.insert("barecodes", &barecodes); - context.insert("barecode", &BareCode::create(template_m)); - context.insert("autos", &autos); - context.insert("auto", &Automotive::create(template_m)); - context.insert("internets", &internets); - context.insert("internet", &Internet::create(template_m)); - context.insert("phones", &phones); - context.insert("phone", &Phone::create(template_m)); - context.insert("filesystems", &filesystems); - context.insert("filesystem", &FileSystem::create(template_m)); - context.insert("jobs", &jobs); - context.insert("job", &Job::create(template_m)); - context.insert("currencies", ¤cies); - context.insert("currency", &Currency::create(template_m)); - context.insert("http_codes", &http_codes); - context.insert("http_code", &Http::create(template_m)); - - let result = Tera::one_off(&contents, &context, true); - - println!("{}", result.unwrap()); + println!("{}", g.render()); } return; } diff --git a/src/template/address.rs b/src/template/address.rs index 7a86107..d7eab0a 100644 --- a/src/template/address.rs +++ b/src/template/address.rs @@ -1,42 +1,12 @@ -use crate::fake::Fake; -use clap::ArgMatches; -use fake::faker::address::raw::{ - CityName, CountryName, Geohash, Latitude, Longitude, StateName, TimeZone, ZipCode, -}; -use fake::locales::EN; use serde::{Deserialize, Serialize}; -use crate::lang_env; - -#[derive(Serialize, Deserialize, Debug)] -pub struct Timezone { - pub description: String, -} - -impl Timezone { - pub fn create(_arg: &ArgMatches) -> Timezone { - Timezone { - description: TimeZone(EN).fake::(), - } - } -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct Coordinate { - pub latitude: String, - pub longitude: String, - pub geohash: String, -} +use fake::Fake; +use clap::ArgMatches; +use fake::faker::address::raw::{CityName, CountryName, StateName, ZipCode}; -impl Coordinate { - pub fn create(arg: &ArgMatches) -> Coordinate { - Coordinate { - latitude: lang_return!(Latitude, arg), - longitude: lang_return!(Longitude, arg), - geohash: Geohash(EN, 11).fake::(), - } - } -} +use crate::template::coordinates::Coordinate; +use crate::template::timezone::Timezone; +use crate::lang_env; #[derive(Serialize, Deserialize, Debug)] pub struct Address { @@ -64,3 +34,11 @@ impl Address { } } } + +create_get_property!( + Address, + city: String, + state: String, + country: String, + zipcode: String +); diff --git a/src/template/automotive.rs b/src/template/automotive.rs index 04299a6..024f58c 100644 --- a/src/template/automotive.rs +++ b/src/template/automotive.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::automotive::raw::LicencePlate; use fake::locales::FR_FR; @@ -16,3 +16,8 @@ impl Automotive { } } } + +create_get_property!( + Automotive, + licence_plate: String +); diff --git a/src/template/barecode.rs b/src/template/barecode.rs index fd3842b..9efa459 100644 --- a/src/template/barecode.rs +++ b/src/template/barecode.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::barcode::raw::{Isbn, Isbn10, Isbn13}; use fake::locales::EN; @@ -20,3 +20,10 @@ impl BareCode { } } } + +create_get_property!( + BareCode, + isbn: String, + isbn10: String, + isbn13: String +); diff --git a/src/template/color.rs b/src/template/color.rs index fc969f8..706c136 100644 --- a/src/template/color.rs +++ b/src/template/color.rs @@ -1,6 +1,6 @@ use random_color::RandomColor; -use crate::fake::{Fake, Faker}; +use fake::{Fake, Faker}; use clap::ArgMatches; use serde::{Deserialize, Serialize}; @@ -25,3 +25,12 @@ impl Color { } } } + +create_get_property!( + Color, + hex: String, + rgb: String, + rgba: String, + hsl: String, + hsla: String +); diff --git a/src/template/coordinates.rs b/src/template/coordinates.rs new file mode 100644 index 0000000..8560a6a --- /dev/null +++ b/src/template/coordinates.rs @@ -0,0 +1,32 @@ +use serde::{Deserialize, Serialize}; + +use fake::Fake; +use clap::ArgMatches; +use fake::faker::address::raw::{Geohash, Latitude, Longitude}; +use fake::locales::EN; + +use crate::lang_env; + +#[derive(Serialize, Deserialize, Debug)] +pub struct Coordinate { + pub latitude: String, + pub longitude: String, + pub geohash: String, +} + +impl Coordinate { + pub fn create(arg: &ArgMatches) -> Coordinate { + Coordinate { + latitude: lang_return!(Latitude, arg), + longitude: lang_return!(Longitude, arg), + geohash: Geohash(EN, 11).fake::(), + } + } +} + +create_get_property!( + Coordinate, + latitude: String, + longitude: String, + geohash: String +); diff --git a/src/template/currency.rs b/src/template/currency.rs index 724c715..0b940c8 100644 --- a/src/template/currency.rs +++ b/src/template/currency.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::currency::raw::{CurrencyCode, CurrencyName, CurrencySymbol}; use serde::{Deserialize, Serialize}; @@ -21,3 +21,10 @@ impl Currency { } } } + +create_get_property!( + Currency, + code: String, + name: String, + symbol: String +); diff --git a/src/template/filesystem.rs b/src/template/filesystem.rs index 875b7c6..9d02c8f 100644 --- a/src/template/filesystem.rs +++ b/src/template/filesystem.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::filesystem::raw::{DirPath, FileExtension, FileName, FilePath, MimeType, Semver}; use fake::locales::EN; @@ -28,3 +28,13 @@ impl FileSystem { } } } + +create_get_property!( + FileSystem, + dir_path: String, + file_extension: String, + file_name: String, + file_path: String, + mime_type: String, + semver: String +); diff --git a/src/template/generator.rs b/src/template/generator.rs new file mode 100644 index 0000000..a81bd50 --- /dev/null +++ b/src/template/generator.rs @@ -0,0 +1,363 @@ +use std::borrow::Borrow; +use std::borrow::Cow; +use std::fmt; + +use clap::ArgMatches; + +use askama_parser::node::{Lit, Loop, Target, Whitespace}; +use askama_parser::{Expr, Node}; + +use super::address::Address; +use super::automotive::Automotive; +use super::barecode::BareCode; +use super::color::Color; +use super::coordinates::Coordinate; +use super::currency::Currency; +use super::filesystem::FileSystem; +use super::http::Http; +use super::internet::Internet; +use super::job::Job; +use super::people::People; +use super::phone::Phone; +use super::timezone::Timezone; + +use super::template_trait::TemplateObject; + +#[derive(Clone, Copy, PartialEq)] +pub enum AstLevel { + Top, + Nested, +} + +#[derive(Clone, Copy)] +enum DisplayWrap { + Unwrapped, +} + +#[derive(Debug, Clone)] +pub struct ParsedError { + pub msg: Cow<'static, str>, +} + +impl ParsedError { + fn new>>(s: S) -> Self { + Self { msg: s.into() } + } +} + +impl std::error::Error for ParsedError {} + +impl fmt::Display for ParsedError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt.write_str(&self.msg) + } +} + +impl From<&'static str> for ParsedError { + #[inline] + fn from(s: &'static str) -> Self { + Self::new(s) + } +} + +impl From for ParsedError { + #[inline] + fn from(s: String) -> Self { + Self::new(s) + } +} + +#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] +pub(crate) enum WhitespaceHandling { + /// The default behaviour. It will leave the whitespace characters "as is". + #[default] + Preserve, +} + +impl From for Whitespace { + fn from(ws: WhitespaceHandling) -> Self { + match ws { + WhitespaceHandling::Preserve => Whitespace::Preserve, + } + } +} + +const LOOP_NAMES: &'static [&'static str] = &[ + "autos", + "barecodes", + "filesystems", + "http_codes", + "internets", + "jobs", + "peoples", + "phones", +]; + +struct LoopObject { + address: Address, + automotive: Automotive, + barecode: BareCode, + color: Color, + coordinates: Coordinate, + currency: Currency, + filesystem: FileSystem, + http: Http, + internet: Internet, + job: Job, + people: People, + phone: Phone, + timezone: Timezone, +} + +pub struct Generator<'a> { + // Suffix whitespace from the previous literal. Will be flushed to the + // output buffer unless suppressed by whitespace suppression on the next + // non-literal. + next_ws: Option<&'a str>, + // Whitespace suppression from the previous non-literal. Will be used to + // determine whether to flush prefix whitespace from the next literal. + skip_ws: WhitespaceHandling, + buf: Buffer, + last_loop_var: Option<&'a str>, + last_loop_object: LoopObject, + template_m: &'a ArgMatches, +} + +impl<'a> Generator<'a> { + pub fn new(template_m: &ArgMatches) -> Generator<'_> { + Generator { + next_ws: None, + skip_ws: WhitespaceHandling::Preserve, + buf: Buffer::new(0), + last_loop_var: None, + last_loop_object: LoopObject { + address: Address::create(template_m), + automotive: Automotive::create(template_m), + barecode: BareCode::create(template_m), + color: Color::create(template_m), + coordinates: Coordinate::create(template_m), + currency: Currency::create(template_m), + filesystem: FileSystem::create(template_m), + http: Http::create(template_m), + internet: Internet::create(template_m), + job: Job::create(template_m), + people: People::create(template_m), + phone: Phone::create(template_m), + timezone: Timezone::create(template_m), + }, + template_m, + } + } + + pub fn handle(&mut self, nodes: &'a [Node<'_>], level: AstLevel) -> Result { + let size_hint = 0; + for n in nodes { + match *n { + Node::Lit(ref lit) => { + self.visit_lit(lit); + } + Node::Expr(_ws, ref val) => { + let mut _vec: Vec<&str> = vec![]; + let _ = self.write_expr(val, &mut _vec)?; + } + Node::Loop(ref loop_block) => { + self.write_loop(loop_block)?; + } + _ => {} + } + } + if AstLevel::Top == level { + //self.next_ws = Some(self.skip_ws.into()); + } + Ok(size_hint) + } + + pub fn render(self) -> String { + self.buf.buf + } + + fn visit_lit(&mut self, lit: &'a Lit<'_>) { + let Lit { lws, val, rws } = *lit; + if !lws.is_empty() { + match self.skip_ws { + WhitespaceHandling::Preserve => { + self.buf.write(lws); + } + } + } + + if !val.is_empty() { + self.skip_ws = WhitespaceHandling::Preserve; + self.buf.write(val); + } + + if !rws.is_empty() { + self.next_ws = Some(rws); + } + } + + fn w_loop(&mut self, value: &str, loop_block: &'a Loop<'_>, args: &Vec) -> Result { + if LOOP_NAMES.contains(&value) && !args.is_empty() { + if let askama_parser::Expr::NumLit(val) = args[0] { + if let Ok(len_of_element) = val.parse::() { + for _n in 0..len_of_element { + self.handle(&loop_block.body, AstLevel::Nested)?; + } + } + } + } + Ok(0) + } + + fn write_loop(&mut self, loop_block: &'a Loop<'_>) -> Result { + if let Target::Name(val) = loop_block.var { + self.last_loop_var = Some(val); + } + + if let Expr::Call(r#box, args) = &loop_block.iter { + if let Expr::Var(value) = r#box.borrow() { + self.w_loop(*value, &loop_block, args)?; + } + } + + Ok(0) + } + + fn dispatch(&mut self, attrs: &mut [&'a str]) -> Result { + if let Some(name) = attrs.last() { + if let Some(parent_name) = attrs.get(attrs.len().saturating_sub(2)) { + match *parent_name { + "address" => { + return write_object(&self.last_loop_object.address, attrs, &mut self.buf); + } + "automotive" => { + return write_object( + &self.last_loop_object.automotive, + attrs, + &mut self.buf, + ); + } + "barecode" => { + return write_object(&self.last_loop_object.barecode, attrs, &mut self.buf); + } + "color" => { + return write_object(&self.last_loop_object.color, attrs, &mut self.buf); + } + "coordinates" => { + return write_object( + &self.last_loop_object.coordinates, + attrs, + &mut self.buf, + ); + } + "currency" => { + return write_object(&self.last_loop_object.currency, attrs, &mut self.buf); + } + "filesystem" => { + return write_object( + &self.last_loop_object.filesystem, + attrs, + &mut self.buf, + ); + } + "http" => { + return write_object(&self.last_loop_object.http, attrs, &mut self.buf); + } + "internet" => { + return write_object(&self.last_loop_object.internet, attrs, &mut self.buf); + } + "job" => { + return write_object(&self.last_loop_object.job, attrs, &mut self.buf); + } + "people" => { + return write_object(&self.last_loop_object.people, attrs, &mut self.buf); + } + "phone" => { + return write_object(&self.last_loop_object.phone, attrs, &mut self.buf); + } + "timezone" => { + return write_object(&self.last_loop_object.timezone, attrs, &mut self.buf); + } + _ => { + let attrs_str = attrs.join("."); + return Err(format!("\"{name}\" in \"{attrs_str}\" doesn't exist.").into()); + } + } + } + } + Ok(DisplayWrap::Unwrapped) + } + + fn write_expr( + &mut self, + val: &'a Expr<'a>, + attrs: &mut Vec<&'a str>, + ) -> Result { + match val { + Expr::Attr(attr, name) => match attr.borrow() { + Expr::Var(parent_name) => { + attrs.insert(0, *name); + attrs.insert(0, *parent_name); + Ok(self.dispatch(attrs)?) + } + _val => { + attrs.insert(0, *name); + self.write_expr(_val, attrs) + } + }, + _ => Ok(DisplayWrap::Unwrapped), + } + } +} + +fn write_object( + object: &T, + attrs: &mut [&str], + buf: &mut Buffer, +) -> Result { + if let Some(name) = attrs.last() { + if let Some(property_value) = object.get_property(name) { + if let Some(value) = property_value.downcast_ref::() { + buf.write(value); + } else { + return Ok(DisplayWrap::Unwrapped); + } + } + } + Ok(DisplayWrap::Unwrapped) +} + +struct Buffer { + // The buffer to generate the code into + buf: String, + // The current level of indentation (in spaces) + indent: u8, + // Whether the output buffer is currently at the start of a line + start: bool, + discard: bool, +} + +impl Buffer { + fn new(indent: u8) -> Self { + Self { + buf: String::new(), + indent, + start: true, + discard: false, + } + } + + fn write(&mut self, s: &str) { + if self.discard { + return; + } + if self.start { + for _ in 0..(self.indent * 4) { + self.buf.push(' '); + } + self.start = false; + } + self.buf.push_str(s); + } +} diff --git a/src/template/http.rs b/src/template/http.rs index de7a90d..f9dc309 100644 --- a/src/template/http.rs +++ b/src/template/http.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::http::raw::{RfcStatusCode, ValidStatusCode}; use fake::locales::EN; @@ -18,3 +18,9 @@ impl Http { } } } + +create_get_property!( + Http, + rfc_status_code: String, + valid_status_code: String +); diff --git a/src/template/internet.rs b/src/template/internet.rs index ec9a4c0..13127c6 100644 --- a/src/template/internet.rs +++ b/src/template/internet.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::internet::raw::*; use fake::locales::EN; @@ -38,3 +38,18 @@ impl Internet { } } } + +create_get_property!( + Internet, + free_email_provider: String, + domain_suffix: String, + free_email: String, + safe_email: String, + username: String, + password: String, + ip: String, + ipv4: String, + ipv6: String, + mac_address: String, + useragent: String +); diff --git a/src/template/job.rs b/src/template/job.rs index 5f2dde3..b720105 100644 --- a/src/template/job.rs +++ b/src/template/job.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::job::raw::{Field, Position, Seniority, Title}; use serde::{Deserialize, Serialize}; @@ -23,3 +23,11 @@ impl Job { } } } + +create_get_property!( + Job, + seniority: String, + field: String, + position: String, + title: String +); diff --git a/src/template/lorem.rs b/src/template/lorem.rs index 38681bb..6458997 100644 --- a/src/template/lorem.rs +++ b/src/template/lorem.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::lorem::raw::{Paragraphs, Sentences, Words}; use fake::locales::EN; diff --git a/src/template/mod.rs b/src/template/mod.rs index ea130e0..a729c9e 100644 --- a/src/template/mod.rs +++ b/src/template/mod.rs @@ -1,9 +1,12 @@ -pub mod parser; +pub mod generator; + +pub mod template_trait; pub mod address; pub mod automotive; pub mod barecode; pub mod color; +pub mod coordinates; pub mod currency; pub mod filesystem; pub mod http; @@ -12,3 +15,4 @@ pub mod job; pub mod lorem; pub mod people; pub mod phone; +pub mod timezone; diff --git a/src/template/parser.rs b/src/template/parser.rs deleted file mode 100644 index 0be6458..0000000 --- a/src/template/parser.rs +++ /dev/null @@ -1,63 +0,0 @@ -use pest::{iterators::Pair, Parser}; -use pest_derive::Parser; - -#[derive(Parser)] -#[grammar = "template/template.pest"] -pub struct TemplateParser; - -pub struct TemplateConst { - pub key: String, - pub value: String, - pub tag: String, -} - -fn parse_set_tag(pair: Pair, pair_str: String) -> TemplateConst { - let mut key = "".to_string(); - let mut expr = "".to_string(); - - for p in pair.into_inner() { - match p.as_rule() { - Rule::ident => key = p.as_str().to_string(), - Rule::logic_expr => expr = p.as_span().as_str().trim().to_string(), - _ => {} - } - } - - TemplateConst { - key, - value: expr, - tag: pair_str, - } -} - -fn parse_content(pair: Pair) -> Vec { - let mut nodes = vec![]; - - for p in pair.into_inner() { - if p.as_rule() == Rule::set_tag { - let pair_str = p.as_str().to_string(); - nodes.push(parse_set_tag(p, pair_str)) - }; - } - - nodes -} - -pub fn parse(input: &str) -> Vec { - let mut nodes = vec![]; - - let mut pairs = match TemplateParser::parse(Rule::template, input) { - Ok(p) => p, - Err(_e) => { - return nodes; - } - }; - - for p in pairs.next().unwrap().into_inner() { - if p.as_rule() == Rule::content { - nodes.extend(parse_content(p)) - } - } - - nodes -} diff --git a/src/template/people.rs b/src/template/people.rs index b291ce9..d2d0c0a 100644 --- a/src/template/people.rs +++ b/src/template/people.rs @@ -6,10 +6,11 @@ use fake::faker::name::raw::{FirstName, LastName, Title}; use fake::locales::EN; use serde::{Deserialize, Serialize}; -use crate::fake::Fake; -use crate::lang_env; +use fake::Fake; use crate::template::{address::Address, automotive::Automotive, job::Job, phone::Phone}; +use crate::lang_env; + #[derive(Serialize, Deserialize, Debug)] pub struct People { pub gender: String, @@ -55,3 +56,13 @@ impl People { } } } + +create_get_property!( + People, + gender: String, + birthday: String, + title: String, + first_name: String, + last_name: String, + location: Address +); diff --git a/src/template/phone.rs b/src/template/phone.rs index 9309070..bf0da7f 100644 --- a/src/template/phone.rs +++ b/src/template/phone.rs @@ -1,4 +1,4 @@ -use crate::fake::Fake; +use fake::Fake; use clap::ArgMatches; use fake::faker::phone_number::raw::{CellNumber, PhoneNumber}; use serde::{Deserialize, Serialize}; @@ -19,3 +19,9 @@ impl Phone { } } } + +create_get_property!( + Phone, + fix: String, + cell: String +); diff --git a/src/template/template.pest b/src/template/template.pest deleted file mode 100644 index 8359038..0000000 --- a/src/template/template.pest +++ /dev/null @@ -1,306 +0,0 @@ -WHITESPACE = _{ " " | "\t" | "\r" | "\n" } - -/// LITERALS -int = @{ "-" ? ~ ("0" | '1'..'9' ~ '0'..'9' * ) } -float = @{ - "-" ? ~ - ( - "0" ~ "." ~ '0'..'9' + | - '1'..'9' ~ '0'..'9' * ~ "." ~ '0'..'9' + - ) -} -// matches anything between 2 double quotes -double_quoted_string = @{ "\"" ~ (!("\"") ~ ANY)* ~ "\""} -// matches anything between 2 single quotes -single_quoted_string = @{ "\'" ~ (!("\'") ~ ANY)* ~ "\'"} -// matches anything between 2 backquotes\backticks -backquoted_quoted_string = @{ "`" ~ (!("`") ~ ANY)* ~ "`"} - -string = @{ - double_quoted_string | - single_quoted_string | - backquoted_quoted_string -} - -boolean = { "true" | "false" | "True" | "False" } - -// ----------------------------------------------- - -/// OPERATORS -op_or = @{ "or" ~ WHITESPACE } -op_and = @{ "and" ~ WHITESPACE } -op_not = @{ "not" ~ WHITESPACE } -op_lte = { "<=" } -op_gte = { ">=" } -op_lt = { "<" } -op_gt = { ">" } -op_eq = { "==" } -op_ineq = { "!=" } -op_plus = { "+" } -op_minus = { "-" } -op_times = { "*" } -op_slash = { "/" } -op_modulo = { "%" } - -// ------------------------------------------------- - -/// Idents - -all_chars = _{'a'..'z' | 'A'..'Z' | "_" | '0'..'9'} -// Used everywhere where an ident is used, except when accessing -// data from the context. -// Eg block name, argument name, macro name etc -ident = @{ - ('a'..'z' | 'A'..'Z' | "_") ~ - all_chars* -} - -// The context_ident used to get data from the context. -// Same as ident but allows `.` in it -dotted_ident = @{ - ('a'..'z' | 'A'..'Z' | "_") ~ - all_chars* ~ - ("." ~ all_chars+)* -} - -square_brackets = @{ - "[" ~ (int | string | dotted_square_bracket_ident) ~ "]" -} - -dotted_square_bracket_ident = @{ - dotted_ident ~ ( ("." ~ all_chars+) | square_brackets )* -} - -string_concat = { (fn_call | float | int | string | dotted_square_bracket_ident) ~ ("~" ~ (fn_call | float | int | string | dotted_square_bracket_ident))+ } - -// ---------------------------------------------------- - -/// EXPRESSIONS -/// We'll use precedence climbing on those in the parser phase - -// boolean first so they are not caught as identifiers -basic_val = _{ boolean | test_not | test | macro_call | fn_call | dotted_square_bracket_ident | float | int } -basic_op = _{ op_plus | op_minus | op_times | op_slash | op_modulo } -basic_expr = { ("(" ~ basic_expr ~ ")" | basic_val) ~ (basic_op ~ basic_val)* } -basic_expr_filter = !{ basic_expr ~ filter* } -string_expr_filter = !{ (string_concat | string) ~ filter* } - -comparison_val = { basic_expr_filter ~ (basic_op ~ basic_expr_filter)* } -comparison_op = _{ op_lte | op_gte | op_gt | op_lt | op_eq | op_ineq } -comparison_expr = { (string_expr_filter | comparison_val) ~ (comparison_op ~ (string_expr_filter | comparison_val))? } - -// The `in` operator -in_cond_container = {string_expr_filter | array_filter | dotted_square_bracket_ident} -in_cond = !{ (string_expr_filter | basic_expr_filter) ~ op_not? ~ "in" ~ in_cond_container } - -logic_val = !{ op_not? ~ (in_cond | comparison_expr) } -logic_expr = !{ logic_val ~ ((op_or | op_and) ~ logic_val)* } - -array = !{ "[" ~ (logic_val ~ ",")* ~ logic_val? ~ "]"} -array_filter = !{ array ~ filter* } - -string_array = !{ "[" ~ (string ~ ",")* ~ string? ~ "]"} - -// ---------------------------------------------------- - -/// FUNCTIONS & FILTERS - -// A keyword argument: something=10, something="a value", something=1+10 etc -kwarg = { ident ~ "=" ~ (logic_expr | array_filter) } -kwargs = _{ kwarg ~ ("," ~ kwarg )* ~ ","? } -fn_call = { ident ~ "(" ~ kwargs? ~ ")" } -filter = { "|" ~ (fn_call | ident) } - - -// ------------------------------------------------------ - -/// MACROS - -// A macro argument can have default value, only a literal though -macro_def_arg = ${ (ident ~ "=" ~ (boolean | string | float | int)) | ident } -macro_def_args = _{ macro_def_arg ~ ("," ~ macro_def_arg)* } -macro_fn = _{ ident ~ "(" ~ macro_def_args? ~ ")" } -macro_fn_wrapper = !{ macro_fn } -macro_call = { ident ~ "::" ~ ident ~ "(" ~ kwargs? ~ ")" } - - -// ------------------------------------------------------- - -/// TESTS - -// It's a bit weird that tests are the only thing in Tera not using kwargs -// but at the same time it's one arg most of the time so... -test_arg = { logic_expr | array_filter } -test_args = _{ test_arg ~ ("," ~ test_arg)* } -test_call = !{ ident ~ ("(" ~ test_args ~ ")")? } -test_not = { dotted_ident ~ "is" ~ "not" ~ test_call } -test = { dotted_ident ~ "is" ~ test_call } - -// ------------------------------------------------------- - -/// TERA - -// All the blocks that Tera recognises -variable_start = { "{{-" | "{{" } -variable_end = { "-}}" | "}}" } -// whitespace control -tag_start = { "{%-" | "{%" } -tag_end = { "-%}" | "%}" } -comment_start = { "{#-" | "{#" } -comment_end = { "-#}" | "#}" } -block_start = _{ variable_start | tag_start | comment_start } - -comment_text = ${ (!(comment_end) ~ ANY)+ } - -// Tag marks -ignore_missing = { "ignore" ~ WHITESPACE* ~ "missing" } - - -// Actual tags -include_tag = ${ tag_start ~ WHITESPACE* ~ "include" ~ WHITESPACE+ ~ (string | string_array) ~ WHITESPACE* ~ ignore_missing? ~ WHITESPACE* ~ tag_end } -comment_tag = ${ comment_start ~ comment_text ~ comment_end } -block_tag = ${ tag_start ~ WHITESPACE* ~ "block" ~ WHITESPACE+ ~ ident ~ WHITESPACE* ~ tag_end } -macro_tag = ${ tag_start ~ WHITESPACE* ~ "macro" ~ WHITESPACE+ ~ macro_fn_wrapper ~ WHITESPACE* ~ tag_end } -if_tag = ${ tag_start ~ WHITESPACE* ~ "if" ~ WHITESPACE+ ~ logic_expr ~ WHITESPACE* ~ tag_end } -elif_tag = ${ tag_start ~ WHITESPACE* ~ "elif" ~ WHITESPACE+ ~ logic_expr ~ WHITESPACE* ~ tag_end } -else_tag = !{ tag_start ~ "else" ~ tag_end } -for_tag = ${ - tag_start ~ WHITESPACE* - ~ "for"~ WHITESPACE+ ~ ident ~ ("," ~ WHITESPACE* ~ ident)? ~ WHITESPACE+ ~ "in" ~ WHITESPACE+ ~ (basic_expr_filter | array_filter) - ~ WHITESPACE* ~ tag_end -} -filter_tag = ${ - tag_start ~ WHITESPACE* - ~ "filter" ~ WHITESPACE+ ~ (fn_call | ident) - ~ WHITESPACE* ~ tag_end -} -set_tag = ${ - tag_start ~ WHITESPACE* - ~ "set" ~ WHITESPACE+ ~ ident ~ WHITESPACE* ~ "=" ~ WHITESPACE* ~ (logic_expr | array_filter) - ~ WHITESPACE* ~ tag_end -} -set_global_tag = ${ - tag_start ~ WHITESPACE* - ~ "set_global" ~ WHITESPACE+ ~ ident ~ WHITESPACE* ~ "=" ~ WHITESPACE* ~ (logic_expr | array_filter) - ~ WHITESPACE* ~ tag_end -} -endblock_tag = !{ tag_start ~ "endblock" ~ ident? ~ tag_end } -endmacro_tag = !{ tag_start ~ "endmacro" ~ ident? ~ tag_end } -endif_tag = !{ tag_start ~ "endif" ~ tag_end } -endfor_tag = !{ tag_start ~ "endfor" ~ tag_end } -endfilter_tag = !{ tag_start ~ "endfilter" ~ tag_end } -break_tag = !{ tag_start ~ "break" ~ tag_end } -continue_tag = !{ tag_start ~ "continue" ~ tag_end } - -variable_tag = !{ variable_start ~ (logic_expr | array_filter) ~ variable_end } -super_tag = !{ variable_start ~ "super()" ~ variable_end } - -text = ${ (!(block_start) ~ ANY)+ } - -raw_tag = !{ tag_start ~ "raw" ~ tag_end } -endraw_tag = !{ tag_start ~ "endraw" ~ tag_end } -raw_text = ${ (!endraw_tag ~ ANY)* } -raw = ${ raw_tag ~ raw_text ~ endraw_tag } - -filter_section = ${ filter_tag ~ filter_section_content* ~ endfilter_tag } - -forloop = ${ for_tag ~ for_content* ~ (else_tag ~ for_content*)* ~ endfor_tag } - -macro_if = ${ if_tag ~ macro_content* ~ (elif_tag ~ macro_content*)* ~ (else_tag ~ macro_content*)? ~ endif_tag } -block_if = ${ if_tag ~ block_content* ~ (elif_tag ~ block_content*)* ~ (else_tag ~ block_content*)? ~ endif_tag } -for_if = ${ if_tag ~ for_content* ~ (elif_tag ~ for_content*)* ~ (else_tag ~ for_content*)? ~ endif_tag } -filter_section_if = ${ if_tag ~ filter_section_content* ~ (elif_tag ~ filter_section_content*)* ~ (else_tag ~ filter_section_content*)? ~ endif_tag } -content_if = ${ if_tag ~ content* ~ (elif_tag ~ content*)* ~ (else_tag ~ content*)? ~ endif_tag } - -block = ${ block_tag ~ block_content* ~ endblock_tag } -macro_definition = ${ macro_tag ~ macro_content* ~ endmacro_tag } - -filter_section_content = @{ - include_tag | - variable_tag | - comment_tag | - set_tag | - set_global_tag | - block | - forloop | - filter_section_if | - raw | - filter_section | - text -} - -// smaller sets of allowed content in macros -macro_content = @{ - include_tag | - variable_tag | - comment_tag | - set_tag | - set_global_tag | - macro_if | - forloop | - filter_section | - raw | - text -} - -// smaller set of allowed content in block -block_content = @{ - include_tag | - super_tag | - variable_tag | - comment_tag | - set_tag | - set_global_tag | - block | - block_if | - forloop | - filter_section | - raw | - text -} - -// set of allowed content inside for loops -for_content = @{ - include_tag | - variable_tag | - comment_tag | - set_tag | - set_global_tag | - for_if | - forloop | - break_tag | - continue_tag | - filter_section | - raw | - text -} - -content = @{ - include_tag | - variable_tag | - comment_tag | - set_tag | - set_global_tag | - macro_definition | - block | - content_if | - forloop | - filter_section | - raw | - text -} - -extends_tag = ${ - WHITESPACE* ~ tag_start ~ WHITESPACE* - ~ "extends" ~ WHITESPACE+ ~ string - ~ WHITESPACE* ~ tag_end ~ WHITESPACE* -} - - -// top level rule -template = ${ - SOI - ~ comment_tag* - ~ content* - ~ EOI -} diff --git a/src/template/template_trait.rs b/src/template/template_trait.rs new file mode 100644 index 0000000..dfaaee7 --- /dev/null +++ b/src/template/template_trait.rs @@ -0,0 +1,5 @@ +use std::any::Any; + +pub trait TemplateObject { + fn get_property(&self, key: &str) -> Option<&dyn Any>; +} diff --git a/src/template/timezone.rs b/src/template/timezone.rs new file mode 100644 index 0000000..8f568d0 --- /dev/null +++ b/src/template/timezone.rs @@ -0,0 +1,24 @@ +use serde::{Deserialize, Serialize}; + +use fake::Fake; +use clap::ArgMatches; +use fake::faker::address::raw::TimeZone; +use fake::locales::EN; + +#[derive(Serialize, Deserialize, Debug)] +pub struct Timezone { + pub description: String, +} + +impl Timezone { + pub fn create(_arg: &ArgMatches) -> Timezone { + Timezone { + description: TimeZone(EN).fake::(), + } + } +} + +create_get_property!( + Timezone, + description: String +); diff --git a/tests/template.rs b/tests/template.rs new file mode 100644 index 0000000..e1be92a --- /dev/null +++ b/tests/template.rs @@ -0,0 +1,47 @@ +use std::fs; + +use clap::{Arg, Command}; +use askama_parser::{Ast, Syntax}; + +use pouf::template::generator::{AstLevel, Generator, ParsedError}; + +fn sample_to_parse(path: &str) -> Result { + let template_m = Command::new("MyApp").arg(Arg::new("out")).get_matches(); + let contents = fs::read_to_string(path).expect("Should have been able to read the file"); + let ast = Ast::from_str(&contents, &Syntax::default()).unwrap(); + let mut g = Generator::new(&template_m); + return g.handle(ast.nodes(), AstLevel::Top); +} + +#[test] +fn test_rated_example_isbn() { + let r = sample_to_parse("examples/templates/isbn.txt"); + if let Err(_err) = r { + assert!(false); + } + else { + assert!(true); + } +} + +#[test] +fn test_rated_example_people() { + let r = sample_to_parse("examples/templates/people.json"); + if let Err(_err) = r { + assert!(false); + } + else { + assert!(true); + } +} + +#[test] +fn test_rated_example_misc() { + let r = sample_to_parse("examples/templates/misc.txt"); + if let Err(_err) = r { + assert!(false); + } + else { + assert!(true); + } +}