From ab76146cec7e8fc8f70bc319a6a6a73577235e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Mon, 13 Jan 2025 01:02:24 +0100 Subject: [PATCH] Add --duplicate-keys option to yamlpp-load* scripts --- bin/yamlpp-load | 5 ++++- bin/yamlpp-load-dump | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/yamlpp-load b/bin/yamlpp-load index 5977dba0..735ce5dc 100755 --- a/bin/yamlpp-load +++ b/bin/yamlpp-load @@ -13,6 +13,7 @@ GetOptions( 'help|h' => \my $help, 'boolean=s' => \my $boolean, 'cyclic' => \my $cyclic, + 'duplicate-keys=i' => \my $duplicate_keys, 'merge' => \my $merge, 'perl' => \my $perl, 'module|M=s' => \my $module, @@ -70,6 +71,7 @@ sub _yamlpp { schema => \@schema, boolean => $boolean, cyclic_refs => $cyclic ? 'allow' : 'fatal', + duplicate_keys => $duplicate_keys ? 1 : 0, preserve => PRESERVE_ORDER, yaml_version => \@yaml_versions, ); @@ -132,7 +134,8 @@ Usage: Options: --boolean= 'perl', 'JSON::PP', 'boolean' - --cyclic Allow cyclic references + --cyclic Set to 1 to allow cyclic references + --duplicate-keys= Set to 1 to allow duplicate keys --merge Enable loading merge keys '<<' --perl Enable loading perl types and objects (use only on trusted input!) diff --git a/bin/yamlpp-load-dump b/bin/yamlpp-load-dump index e89eece9..b344a867 100755 --- a/bin/yamlpp-load-dump +++ b/bin/yamlpp-load-dump @@ -15,6 +15,7 @@ GetOptions( 'help|h' => \my $help, 'boolean=s' => \my $boolean, 'cyclic' => \my $cyclic, + 'duplicate-keys=i' => \my $duplicate_keys, 'indent=i' => \my $indent, 'width=i' => \my $width, 'header!' => \my $header, @@ -131,6 +132,7 @@ sub _yamlpp { schema => \@schema, boolean => $boolean, cyclic_refs => $cyclic ? 'allow' : 'fatal', + duplicate_keys => $duplicate_keys ? 1 : 0, preserve => $preserve, indent => $indent, width => $width, @@ -278,7 +280,8 @@ Usage: Options: --boolean= 'perl', 'JSON::PP', 'boolean' - --cyclic Allow cyclic references + --cyclic Set to 1 to allow cyclic references + --duplicate-keys= Set to 1 to allow duplicate keys --indent= Number of spaces for indentation --width= Maximum column width (only used in flow style for now) --[no-]header Print '---' (default)