Added format filter to enforce formatting on array objects
This commit is contained in:
@@ -41,6 +41,12 @@ module CliGen
|
|||||||
{% format = format.resolve if format.is_a? Path %}
|
{% 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 %}
|
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided format must be a RegexLiteral" unless format.is_a? RegexLiteral %}
|
||||||
{% end %}
|
{% 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}})]
|
@[CliGen::Argument(short: {{short}}, long: {{long}}, description: {{description}}, validation: {{validation}}, on_match: {{on_match}}, options: {{options}}, delimiter: {{delimiter}}, format: {{format}})]
|
||||||
@{{variable}}
|
@{{variable}}
|
||||||
|
|||||||
Reference in New Issue
Block a user