From b1cbad311b2a0dc69adc41e6242af1f8e6d4cb31 Mon Sep 17 00:00:00 2001 From: Aria Beingessner Date: Fri, 1 Dec 2023 16:45:02 -0500 Subject: [PATCH] feat(kdl): mommy wants to be more cuddly~ kdl (pronounced 'cuddle') is slightly less tedious than JSON and 100% funnier for The Brand~ unfortunately the serde backend for kdl is uhhh Very Incomplete, so mommy opted to use the off-brand-serde-for-kdl, knuffel, which requires a lot more hand-holding~ --- Cargo.lock | 578 ++++++++++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 5 +- build.rs | 73 +++++-- responses.json | 171 --------------- responses.kdl | 157 ++++++++++++++ 5 files changed, 762 insertions(+), 222 deletions(-) delete mode 100644 responses.json create mode 100644 responses.kdl diff --git a/Cargo.lock b/Cargo.lock index f1dd968..f056da9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,33 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.2" @@ -11,15 +38,65 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "backtrace-ext" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50" +dependencies = [ + "backtrace", +] + +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "cargo-mommy" version = "0.3.1" dependencies = [ "fastrand", + "knuffel", + "miette", "regex", - "serde", - "serde-tuple-vec-map", - "serde_json", +] + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", ] [[package]] @@ -28,6 +105,25 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chumsky" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eebd66744a15ded14960ab4ccdbfb51ad3b81f51f3f04a80adac98c985396c9" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -37,6 +133,37 @@ dependencies = [ "instant", ] +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + [[package]] name = "instant" version = "0.1.12" @@ -47,10 +174,60 @@ dependencies = [ ] [[package]] -name = "itoa" -version = "1.0.9" +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "is_ci" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" + +[[package]] +name = "knuffel" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04bee6ddc6071011314b1ce4f7705fef6c009401dba4fd22cb0009db6a177413" +dependencies = [ + "base64", + "chumsky", + "knuffel-derive", + "miette", + "thiserror", + "unicode-width", +] + +[[package]] +name = "knuffel-derive" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91977f56c49cfb961e3d840e2e7c6e4a56bde7283898cf606861f1421348283d" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "libc" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "linux-raw-sys" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "memchr" @@ -58,6 +235,92 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "miette" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +dependencies = [ + "backtrace", + "backtrace-ext", + "is-terminal", + "miette-derive", + "once_cell", + "owo-colors", + "supports-color", + "supports-hyperlinks", + "supports-unicode", + "terminal_size", + "textwrap", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.69" @@ -106,49 +369,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] -name = "ryu" -version = "1.0.15" +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] [[package]] -name = "serde" -version = "1.0.192" +name = "smawk" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" dependencies = [ - "serde_derive", + "is-terminal", + "is_ci", ] [[package]] -name = "serde-tuple-vec-map" -version = "1.0.1" +name = "supports-hyperlinks" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a04d0ebe0de77d7d445bb729a895dcb0a288854b267ca85f030ce51cdc578c82" +checksum = "f84231692eb0d4d41e4cdd0cabfdd2e6cd9e255e65f80c9aa7c98dd502b4233d" dependencies = [ - "serde", + "is-terminal", ] [[package]] -name = "serde_derive" -version = "1.0.192" +name = "supports-unicode" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "4b6c2cb240ab5dd21ed4906895ee23fe5a48acdbd15a3ce388e7b62a9b66baf7" dependencies = [ - "proc-macro2", - "quote", - "syn", + "is-terminal", ] [[package]] -name = "serde_json" -version = "1.0.108" +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "itoa", - "ryu", - "serde", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] @@ -162,8 +443,247 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "textwrap" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +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-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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "zerocopy" +version = "0.7.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] diff --git a/Cargo.toml b/Cargo.toml index f34880d..743609c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,10 +19,9 @@ yikes = [] fastrand = "1.8.0" [build-dependencies] -serde = { version = "1.0.151", features = ["derive"] } -serde_json = "1.0.91" -serde-tuple-vec-map = "1.0.1" regex = "1.10.2" +knuffel = "3.2.0" +miette = { version = "5.10.0", features = ["fancy"] } [workspace.metadata.release] shared-version = true diff --git a/build.rs b/build.rs index 2f32a6b..3039909 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,10 @@ -//! Code that statically parses responses.json and adds it to the codebase~ +//! Code that statically parses responses.kdl and adds it to the codebase~ //! //! This allows the binary to only include what it needs, both perf-wise //! and oh-god-i-found-these-strings-in-this-binary-wise. //! //! How to add a new mood, simply add a new entry to the `moods` object in -//! `responses.json`. Make sure to add `vars` entries for any new variables you +//! `responses.kdl`. Make sure to add `vars` entries for any new variables you //! introduce. //! //! If your new mood or variable include... "spicy" terms, make sure to set an @@ -17,12 +17,17 @@ use std::fs; use std::ops::Range; use std::path::Path; +use knuffel::ast::SpannedNode; +use knuffel::decode::Context; +use knuffel::errors::DecodeError; +use knuffel::traits::ErrorSpan; +use knuffel::Decode; use regex::Regex; -const RESPONSES: &str = include_str!("./responses.json"); +const RESPONSES: &str = include_str!("./responses.kdl"); -#[derive(PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)] -#[serde(rename_all = "snake_case")] +#[derive(PartialEq, Eq, PartialOrd, Ord, knuffel::DecodeScalar, Copy, Clone)] +// TODO: #[serde(rename_all = "snake_case")] enum Spiciness { Chill, Thirsty, @@ -45,43 +50,71 @@ impl Default for Spiciness { } } -#[derive(serde::Deserialize)] +#[derive(knuffel::Decode)] struct Mood { + #[knuffel(child, unwrap(arguments))] positive: Vec, + #[knuffel(child, unwrap(arguments))] negative: Vec, + #[knuffel(child, unwrap(arguments))] overflow: Vec, - #[serde(default)] + #[knuffel(child, default, unwrap(argument))] spiciness: Spiciness, } -#[derive(serde::Deserialize)] +#[derive(knuffel::Decode)] struct Var { + #[knuffel(child, unwrap(arguments))] defaults: Vec, - #[serde(default)] + #[knuffel(child, unwrap(argument))] env_key: Option, - - #[serde(default)] + #[knuffel(child, default, unwrap(argument))] spiciness: Spiciness, // Mommy needs a way to reference variables by index when doing template // substitution. This type is the value of an ordered map, so we can just // stick an index in after parsing~ - #[serde(skip)] index: usize, } -#[derive(serde::Deserialize)] +#[derive(knuffel::Decode)] struct Config { - vars: BTreeMap, - moods: BTreeMap, + #[knuffel(child)] + vars: KdlMap, + #[knuffel(child)] + moods: KdlMap, +} + +struct KdlMap(BTreeMap); +impl, S: ErrorSpan> Decode for KdlMap { + fn decode_node(node: &SpannedNode, ctx: &mut Context) -> Result> { + let mut result = BTreeMap::::new(); + for child in node.children() { + let key = &child.node_name; + let val = V::decode_node(child, ctx)?; + result.insert(key.to_string(), val); + } + Ok(Self(result)) + } +} +impl std::ops::Deref for KdlMap { + type Target = BTreeMap; + fn deref(&self) -> &Self::Target { + &self.0 + } +} +impl std::ops::DerefMut for KdlMap { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } } -fn main() { +fn main() -> Result<(), miette::Report> { let out_dir = &env::var("OUT_DIR").unwrap(); let dest_path = Path::new(out_dir).join("responses.rs"); - let mut config: Config = serde_json::from_str(RESPONSES).unwrap(); + let mut config: Config = knuffel::parse("responses.kdl", RESPONSES)?; let mut i = 0; let mut vars = String::new(); for (name, var) in config.vars.iter_mut() { @@ -104,7 +137,7 @@ fn main() { let pattern = Regex::new(r"\{\w+\}").unwrap(); let mut responses = String::new(); - for (name, mood) in &config.moods { + for (name, mood) in &*config.moods { if mood.spiciness > Spiciness::CONFIGURED { continue; } @@ -176,5 +209,7 @@ fn main() { ) .unwrap(); - println!("cargo:rerun-if-changed=responses.json"); + println!("cargo:rerun-if-changed=responses.kdl"); + + Ok(()) } diff --git a/responses.json b/responses.json deleted file mode 100644 index da36ef7..0000000 --- a/responses.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "moods": { - "chill": { - "positive": [ - "*pets your head*", - "*gives you scritches*", - "you're such a smart cookie~", - "that's a good {affectionate_term}~", - "{role} thinks {pronoun} little {affectionate_term} earned a big hug~", - "good {affectionate_term}~\n{role}'s so proud of you~", - "aww, what a good {affectionate_term}~\n{role} knew you could do it~", - "you did it~!", - "{role} loves you~", - "*gives you a sticker*", - "*boops your nose*", - "*wraps you in a big hug*", - "well done~!\n{role} is so happy for you~", - "what a good {affectionate_term} you are~", - "that's {role}'s clever little {affectionate_term}~", - "you're doing so well~!", - "you're making {role} so happy~", - "{role} loves {pronoun} cute little {affectionate_term}~" - ], - "negative": [ - "{role} believes in you~", - "don't forget to hydrate~", - "aww, you'll get it next time~", - "do you need {role}'s help~?", - "everything's gonna be ok~", - "{role} still loves you no matter what~", - "oh no did {role}'s little {affectionate_term} make a big mess~?", - "{role} knows {pronoun} little {affectionate_term} can do better~", - "{role} still loves you~", - "{role} thinks {pronoun} little {affectionate_term} is getting close~", - "it's ok, {role}'s here for you~", - "oh, darling, you're almost there~", - "does {role}'s little {affectionate_term} need a bit of a break~?", - "oops~! {role} loves you anyways~", - "try again for {role}, {affectionate_term}~", - "don't worry, {role} knows you can do it~" - ], - "overflow": [ - "{role} has executed too many times and needs to take a nap~" - ] - }, - "ominous": { - "positive": [ - "What you have set in motion today will be remembered for aeons to come!", - "{role} will see to it that {pronoun} little {affectionate_term}'s name is feared~", - "{role} is proud of the evil seed {pronoun} {affectionate_term} has planted into this accursed world" - ], - "negative": [ - "Ah, failure? {role} will make sure the stars are right next time", - "Does {role}'s little {affectionate_term} need more time for worship~?", - "May the mark of the beast stain your flesh forever, {role} will haunt your soul forevermore" - ], - "overflow": [ - "THOU HAST DRUNK TOO DEEPLY OF THE FONT" - ] - }, - - - - - - - - - - - - - - "thirsty": { - "spiciness": "thirsty", - "positive": [ - "*tugs your leash*\nthat's a VERY good {affectionate_term}~", - "*runs {pronoun} fingers through your hair* good {affectionate_term}~ keep going~", - "*smooches your forehead*\ngood job~", - "*nibbles on your ear*\nthat's right~\nkeep going~", - "*pats your butt*\nthat's a good {affectionate_term}~", - "*drags {pronoun} nail along your cheek*\nsuch a good {affectionate_term}~", - "*bites {pronoun} lip*\nmhmm~", - "give {role} a kiss~", - "*heavy breathing against your neck*" - ], - "negative": [ - "you're so cute when you're flustered~", - "do you think you're going to get a reward from {role} like that~?", - "*grabs your hair and pulls your head back*\nyou can do better than that for {role} can't you~?", - "if you don't learn how to code better, {role} is going to put you in time-out~", - "does {role} need to give {pronoun} little {affectionate_term} some special lessons~?", - "you need to work harder to please {role}~", - "gosh you must be flustered~", - "are you just keysmashing now~?\ncute~", - "is {role}'s little {affectionate_term} having trouble reaching the keyboard~?" - ], - "overflow": [ - "you've been a bad little {affectionate_term} and worn out {role}~" - ] - }, - - "yikes": { - "spiciness": "yikes", - "positive": [ - "keep it up and {role} might let you cum you little {denigrating_term}~", - "good {denigrating_term}~\nyou've earned five minutes with the buzzy wand~", - "mmm~ come taste {role}'s {part}~", - "*slides {pronoun} finger in your mouth*\nthat's a good little {denigrating_term}~", - "you're so good with your fingers~\n{role} knows where {pronoun} {denigrating_term} should put them next~", - "{role} is getting hot~", - "that's a good {denigrating_term}~", - "yes~\nyes~~\nyes~~~", - "{role}'s going to keep {pronoun} good little {denigrating_term}~", - "Open wide {denigrating_term}. you've earned {role}'s {part}~", - "Do you want {role}'s {part}? Keep this up and you'll earn it~", - "Oooh~ what a good {denigrating_term} you are.~" - ], - "negative": [ - "you filthy {denigrating_term}~\nyou made a mess, now clean it up~\nwith your tongue~", - "*picks you up by the throat*\npathetic~", - "*drags {pronoun} claws down your back*\ndo it again~", - "*brandishes {pronoun} paddle*\ndon't make me use this~", - "{denigrating_term}.\n{denigrating_term}~\n{denigrating_term}~~", - "get on your knees and beg {role} for forgiveness you {denigrating_term}~", - "{role} doesn't think {pronoun} little {denigrating_term} should have permission to wear clothes anymore~", - "never forget you belong to {role}~", - "does {role} need to put you in the {denigrating_term} wiggler~?", - "{role} is starting to wonder if you should just give up and become {pronoun} breeding stock~", - "On your knees {denigrating_term}~", - "Oh dear. {role} is not pleased", - "One spank per error sounds appropriate, don't you think {denigrating_term}?", - "No more {part} for you {denigrating_term}" - ], - "overflow": [ - "brats like you don't get to talk to {role}" - ] - } - }, - - "vars": { - "mood": { - "defaults": ["chill"] - }, - "emote": { - "defaults": ["❤️", "💖", "💗", "💓", "💞"] - }, - "pronoun": { - "defaults": ["her"] - }, - "role": { - "defaults": [] - }, - - "affectionate_term": { - "defaults": ["girl"], - "env_key": "LITTLE" - }, - - "denigrating_term": { - "spiciness": "yikes", - "defaults": ["slut", "toy", "pet", "pervert", "whore"], - "env_key": "FUCKING" - }, - "part": { - "spiciness": "yikes", - "defaults": ["milk"] - } - } -} - diff --git a/responses.kdl b/responses.kdl new file mode 100644 index 0000000..f6dc04e --- /dev/null +++ b/responses.kdl @@ -0,0 +1,157 @@ +moods { + chill { + positive \ + "*pets your head*" \ + "*gives you scritches*" \ + "you're such a smart cookie~" \ + "that's a good {affectionate_term}~" \ + "{role} thinks {pronoun} little {affectionate_term} earned a big hug~" \ + "good {affectionate_term}~\n{role}'s so proud of you~" \ + "aww, what a good {affectionate_term}~\n{role} knew you could do it~" \ + "you did it~!" \ + "{role} loves you~" \ + "*gives you a sticker*" \ + "*boops your nose*" \ + "*wraps you in a big hug*" \ + "well done~!\n{role} is so happy for you~" \ + "what a good {affectionate_term} you are~" \ + "that's {role}'s clever little {affectionate_term}~" \ + "you're doing so well~!" \ + "you're making {role} so happy~" \ + "{role} loves {pronoun} cute little {affectionate_term}~" + negative \ + "{role} believes in you~" \ + "don't forget to hydrate~" \ + "aww, you'll get it next time~" \ + "do you need {role}'s help~?" \ + "everything's gonna be ok~" \ + "{role} still loves you no matter what~" \ + "oh no did {role}'s little {affectionate_term} make a big mess~?" \ + "{role} knows {pronoun} little {affectionate_term} can do better~" \ + "{role} still loves you~" \ + "{role} thinks {pronoun} little {affectionate_term} is getting close~" \ + "it's ok, {role}'s here for you~" \ + "oh, darling, you're almost there~" \ + "does {role}'s little {affectionate_term} need a bit of a break~?" \ + "oops~! {role} loves you anyways~" \ + "try again for {role}, {affectionate_term}~" \ + "don't worry, {role} knows you can do it~" + overflow \ + "{role} has executed too many times and needs to take a nap~" + } + + ominous { + positive \ + "What you have set in motion today will be remembered for aeons to come!" \ + "{role} will see to it that {pronoun} little {affectionate_term}'s name is feared~" \ + "{role} is proud of the evil seed {pronoun} {affectionate_term} has planted into this accursed world" + negative \ + "Ah, failure? {role} will make sure the stars are right next time" \ + "Does {role}'s little {affectionate_term} need more time for worship~?" \ + "May the mark of the beast stain your flesh forever, {role} will haunt your soul forevermore" + overflow \ + "THOU HAST DRUNK TOO DEEPLY OF THE FONT" + } + + + + + + // !!!!!! NSFW !!!!!!! + + + + thirsty { + spiciness "thirsty" + positive \ + "*tugs your leash*\nthat's a VERY good {affectionate_term}~" \ + "*runs {pronoun} fingers through your hair* good {affectionate_term}~ keep going~" \ + "*smooches your forehead*\ngood job~" \ + "*nibbles on your ear*\nthat's right~\nkeep going~" \ + "*pats your butt*\nthat's a good {affectionate_term}~" \ + "*drags {pronoun} nail along your cheek*\nsuch a good {affectionate_term}~" \ + "*bites {pronoun} lip*\nmhmm~" \ + "give {role} a kiss~" \ + "*heavy breathing against your neck*" + negative \ + "you're so cute when you're flustered~" \ + "do you think you're going to get a reward from {role} like that~?" \ + "*grabs your hair and pulls your head back*\nyou can do better than that for {role} can't you~?" \ + "if you don't learn how to code better, {role} is going to put you in time-out~" \ + "does {role} need to give {pronoun} little {affectionate_term} some special lessons~?" \ + "you need to work harder to please {role}~" \ + "gosh you must be flustered~" \ + "are you just keysmashing now~?\ncute~" \ + "is {role}'s little {affectionate_term} having trouble reaching the keyboard~?" + overflow \ + "you've been a bad little {affectionate_term} and worn out {role}~" + } + + yikes { + spiciness "yikes" + positive \ + "keep it up and {role} might let you cum you little {denigrating_term}~" \ + "good {denigrating_term}~\nyou've earned five minutes with the buzzy wand~" \ + "mmm~ come taste {role}'s {part}~" \ + "*slides {pronoun} finger in your mouth*\nthat's a good little {denigrating_term}~" \ + "you're so good with your fingers~\n{role} knows where {pronoun} {denigrating_term} should put them next~" \ + "{role} is getting hot~" \ + "that's a good {denigrating_term}~" \ + "yes~\nyes~~\nyes~~~" \ + "{role}'s going to keep {pronoun} good little {denigrating_term}~" \ + "Open wide {denigrating_term}. you've earned {role}'s {part}~" \ + "Do you want {role}'s {part}? Keep this up and you'll earn it~" \ + "Oooh~ what a good {denigrating_term} you are.~" + negative \ + "you filthy {denigrating_term}~\nyou made a mess, now clean it up~\nwith your tongue~" \ + "*picks you up by the throat*\npathetic~" \ + "*drags {pronoun} claws down your back*\ndo it again~" \ + "*brandishes {pronoun} paddle*\ndon't make me use this~" \ + "{denigrating_term}.\n{denigrating_term}~\n{denigrating_term}~~" \ + "get on your knees and beg {role} for forgiveness you {denigrating_term}~" \ + "{role} doesn't think {pronoun} little {denigrating_term} should have permission to wear clothes anymore~" \ + "never forget you belong to {role}~" \ + "does {role} need to put you in the {denigrating_term} wiggler~?" \ + "{role} is starting to wonder if you should just give up and become {pronoun} breeding stock~" \ + "On your knees {denigrating_term}~" \ + "Oh dear. {role} is not pleased" \ + "One spank per error sounds appropriate, don't you think {denigrating_term}?" \ + "No more {part} for you {denigrating_term}" + overflow \ + "brats like you don't get to talk to {role}" + } +} + + +vars { + mood { + defaults "chill" + } + emote { + defaults "❤️" "💖" "💗" "💓" "💞" + } + pronoun { + defaults "her" + } + role { + defaults + } + affectionate_term { + env-key "LITTLE" + defaults "girl" + } + + + // !!!!!!! NSFW !!!!!!! + + + denigrating_term { + env-key "FUCKING" + spiciness "yikes" + defaults "slut" "toy" "pet" "pervert" "whore" + } + part { + spiciness "yikes" + defaults "milk" + } +} \ No newline at end of file