From a1a9c6fc04748ab5c3ebaaaa735fdd689fce8842 Mon Sep 17 00:00:00 2001 From: Tristan Ancelet Date: Wed, 12 Aug 2026 16:26:35 -0500 Subject: [PATCH] Added format filter to enforce formatting on array objects --- src/cligen/command/argument.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cligen/command/argument.cr b/src/cligen/command/argument.cr index a443ab0..c3f88eb 100644 --- a/src/cligen/command/argument.cr +++ b/src/cligen/command/argument.cr @@ -41,6 +41,12 @@ module CliGen {% format = format.resolve if format.is_a? Path %} {% raise "ERROR : CliGen::Command.argument(#{name}) : Provided format must be a RegexLiteral" unless format.is_a? RegexLiteral %} {% end %} + {% if type.resolve <= Array && format.nil? %} + {% elem = type.type_vars.first %} + {% unless elem == Int32 %} + {% raise "ERROR : CliGen::Command.argument(#{name}) : When providing custom data types for Array(T) or using Array(String) you must provide a format for argument filtering so that parsing can be done deterministically" %} + {% end %} + {% end %} @[CliGen::Argument(short: {{short}}, long: {{long}}, description: {{description}}, validation: {{validation}}, on_match: {{on_match}}, options: {{options}}, delimiter: {{delimiter}}, format: {{format}})] @{{variable}}