Added allow_no_verification for users to bypass the 'must have options or validation' check. However, not doing so can cause unexpected failures where flags will begin consuming preceeding arguments

This commit is contained in:
Tristan Ancelet
2026-08-14 14:14:53 -05:00
parent f55cc25f2d
commit fd510469ac
+2 -2
View File
@@ -1,6 +1,6 @@
module CliGen module CliGen
class Command class Command
macro argument(variable, description, long = nil, short = nil, validation = nil, on_match = nil, def_setter = false, def_getter = false, options = nil, delimiter = ",", format = nil) macro argument(variable, description, long = nil, short = nil, validation = nil, on_match = nil, def_setter = false, def_getter = false, options = nil, delimiter = ",", format = nil, allow_no_verification = false)
{% raise "ERROR : CliGen::Command.argument : def_setter must be a Bool" unless def_setter.is_a? BoolLiteral %} {% raise "ERROR : CliGen::Command.argument : def_setter must be a Bool" unless def_setter.is_a? BoolLiteral %}
{% raise "ERROR : CliGen::Command.argument : First argument (#{variable}) must be a TypeDeclaration (ex: '<var> : <type> [= val]')" unless variable.is_a? TypeDeclaration %} {% raise "ERROR : CliGen::Command.argument : First argument (#{variable}) must be a TypeDeclaration (ex: '<var> : <type> [= val]')" unless variable.is_a? TypeDeclaration %}
{% name = variable.var %} {% name = variable.var %}
@@ -45,7 +45,7 @@ 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 %} {% if type.resolve <= Array && ! allow_no_verification %}
{% elem = type.type_vars.first %} {% elem = type.type_vars.first %}
{% unless elem == Int32 %} {% unless elem == Int32 %}
{% if format.nil? && options.nil? %} {% if format.nil? && options.nil? %}