himitsu: himitsu::query: Add error message about duplicate keys v1 REJECTED

: 1
 himitsu::query: Add error message about duplicate keys

 1 files changed, 12 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/himitsu-devel/patches/48768/mbox | git am -3
Learn more about email & git

[PATCH himitsu] himitsu::query: Add error message about duplicate keys Export this patch

From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>

Otherwise it would silently abort.
 himitsu/query/parse.ha | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/himitsu/query/parse.ha b/himitsu/query/parse.ha
index e9c2722..a44cba8 100644
--- a/himitsu/query/parse.ha
+++ b/himitsu/query/parse.ha
@@ -122,6 +122,18 @@ export fn parse_items(items: []str) (query | error) = {
	let prev = keys[0];
	for (let i = 1z; i < len(keys); i += 1) {
		if (prev == keys[i]) {
			fmt::printf("himitsud: Duplicate key '{}' in entry:", prev)!;
			for (let i = 0z; i < len(query.items); i += 1) {
				let p = query.items[i];
				fmt::printf(" {}", p.key)!;
				if (!p.private) {
					fmt::printf("={}", p.value)!;
				} else {

			return dupkeys;
		prev = keys[i];
query::parse_items should not have the side-effect of writing error
messages to stdout. It does not fail silently since it returns the
dupkeys error.

I think figuring out what keys are duplicates can easily be done by the
user. Though if this is really a desired feature, the output should be
done at the tool that uses query::parse. The tool must then figure out
the duplicates on their own, but then a method to find duplicates could
be provided by the query module.