Added format filter to enforce formatting on array objects

This commit is contained in:
Tristan Ancelet
2026-08-12 16:26:35 -05:00
parent ffde5165f7
commit a1a9c6fc04
+6
View File
@@ -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}}