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:
@@ -1,6 +1,6 @@
|
||||
module CliGen
|
||||
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 : First argument (#{variable}) must be a TypeDeclaration (ex: '<var> : <type> [= val]')" unless variable.is_a? TypeDeclaration %}
|
||||
{% name = variable.var %}
|
||||
@@ -45,7 +45,7 @@ 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 %}
|
||||
{% if type.resolve <= Array && ! allow_no_verification %}
|
||||
{% elem = type.type_vars.first %}
|
||||
{% unless elem == Int32 %}
|
||||
{% if format.nil? && options.nil? %}
|
||||
|
||||
Reference in New Issue
Block a user