added a few things
This commit is contained in:
@@ -28,6 +28,10 @@ module CliGen
|
|||||||
@{{var.id}} = {{var.default_value}}
|
@{{var.id}} = {{var.default_value}}
|
||||||
{% end %}
|
{% end %}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
|
{% if @type.has_method? :after_initialize %}
|
||||||
|
after_initialize
|
||||||
|
{% end %}
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ module CliGen
|
|||||||
end
|
end
|
||||||
|
|
||||||
when MatchType::NoMatch
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -255,7 +255,8 @@ module CliGen
|
|||||||
{% if T.has_method?(:main) %}
|
{% if T.has_method?(:main) %}
|
||||||
cls.main
|
cls.main
|
||||||
{% else %}
|
{% 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
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|||||||
+4
-6
@@ -61,12 +61,10 @@ module CliGen
|
|||||||
|
|
||||||
def process(argv : Array(Arg) = [] of Arg) : Nil
|
def process(argv : Array(Arg) = [] of Arg) : Nil
|
||||||
if requires_arg?
|
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
|
end
|
||||||
|
|
||||||
if argv.first.flag?
|
|
||||||
abort "ERROR : Flag({{T}}) : Provided argument was a flag (#{argv.first.value})"
|
|
||||||
end
|
|
||||||
|
|
||||||
{% if T == Bool %}
|
{% if T == Bool %}
|
||||||
@value = true
|
@value = true
|
||||||
@@ -101,7 +99,7 @@ module CliGen
|
|||||||
{% elsif T == String %} # String
|
{% elsif T == String %} # String
|
||||||
@value = argv.first.value
|
@value = argv.first.value
|
||||||
argv.first.processed
|
argv.first.processed
|
||||||
{% elsif T.class < CliGen::Parseable %}
|
{% elsif T.class < CliGen::Parsable %}
|
||||||
processed = argv.select(&.processed?)
|
processed = argv.select(&.processed?)
|
||||||
@value = T.parse_args(argv)
|
@value = T.parse_args(argv)
|
||||||
post_processed = argv.select(&.processed?)
|
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"
|
raise "ERROR : Flag({{T}}, long: #{@long_key})#process : Your {{T}}#process_args did not mark processed args as processed. Please check your code"
|
||||||
end
|
end
|
||||||
{% else %}
|
{% 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 %}
|
{% end %}
|
||||||
|
|
||||||
validate!
|
validate!
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module CliGen::Parseable
|
module CliGen::Parsable
|
||||||
abstract def parse_args(args : Array(CliGen::Arg))
|
abstract def parse_args(args : Array(CliGen::Arg))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user