added a few things
This commit is contained in:
@@ -28,6 +28,10 @@ module CliGen
|
||||
@{{var.id}} = {{var.default_value}}
|
||||
{% end %}
|
||||
{% end %}
|
||||
|
||||
{% if @type.has_method? :after_initialize %}
|
||||
after_initialize
|
||||
{% end %}
|
||||
{% end %}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -235,7 +235,7 @@ module CliGen
|
||||
end
|
||||
|
||||
when MatchType::NoMatch
|
||||
raise "ERROR : CommandNode(#{@name}).process : No command, subcommand or flag match for '#{arg.value}'"
|
||||
abort "ERROR : CommandNode(#{@name}).process : No command, subcommand or flag match for '#{arg.value}'"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -255,7 +255,8 @@ module CliGen
|
||||
{% if T.has_method?(:main) %}
|
||||
cls.main
|
||||
{% else %}
|
||||
raise "ERROR : CommandNode({{T}})\#{{@def.name}} : No subcommand matched and no #main defined"
|
||||
abort help
|
||||
#raise "ERROR : CommandNode({{T}})\#{{@def.name}} : No subcommand matched and no #main defined"
|
||||
{% end %}
|
||||
end
|
||||
{% end %}
|
||||
|
||||
+4
-6
@@ -61,12 +61,10 @@ module CliGen
|
||||
|
||||
def process(argv : Array(Arg) = [] of Arg) : Nil
|
||||
if requires_arg?
|
||||
raise "ERROR : Flag({{T}}) : Array requires an argument but provided array is empty" if argv.empty?
|
||||
raise "ERROR : Flag(#{T}, long: #{@long_key}) : Array requires an argument but provided array is empty" if argv.empty?
|
||||
abort "ERROR : Flag(#{T}, long: #{@long_key}) : Provided argument was a flag (#{argv.first.value})" if argv.first.flag?
|
||||
end
|
||||
|
||||
if argv.first.flag?
|
||||
abort "ERROR : Flag({{T}}) : Provided argument was a flag (#{argv.first.value})"
|
||||
end
|
||||
|
||||
{% if T == Bool %}
|
||||
@value = true
|
||||
@@ -101,7 +99,7 @@ module CliGen
|
||||
{% elsif T == String %} # String
|
||||
@value = argv.first.value
|
||||
argv.first.processed
|
||||
{% elsif T.class < CliGen::Parseable %}
|
||||
{% elsif T.class < CliGen::Parsable %}
|
||||
processed = argv.select(&.processed?)
|
||||
@value = T.parse_args(argv)
|
||||
post_processed = argv.select(&.processed?)
|
||||
@@ -109,7 +107,7 @@ module CliGen
|
||||
raise "ERROR : Flag({{T}}, long: #{@long_key})#process : Your {{T}}#process_args did not mark processed args as processed. Please check your code"
|
||||
end
|
||||
{% else %}
|
||||
{% raise "ERROR : Flag({{T}}#process : Generic Type #{T} is not supported. To add support you must include CliGen::Parsable & implement the class method" %}
|
||||
{% raise "ERROR : Flag({{T}}#process : Generic Type #{T} is not supported. To add support you must extend with CliGen::Parsable & implement the class method" %}
|
||||
{% end %}
|
||||
|
||||
validate!
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module CliGen::Parseable
|
||||
module CliGen::Parsable
|
||||
abstract def parse_args(args : Array(CliGen::Arg))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user