Testing
This commit is contained in:
@@ -33,23 +33,22 @@ module CliGenerator
|
||||
end
|
||||
|
||||
macro define_actions
|
||||
ACTIONS : Array(String) = {{@type.class.methods.select(&.annotation(::CliGenerator::SubCommand)).map(&.name.stringify)}}
|
||||
ACTIONS = {{@type.class.methods.select(&.annotation(::CliGenerator::SubCommand)).map(&.name.stringify)}} of String
|
||||
end
|
||||
|
||||
macro define_header
|
||||
{% name = @type.name.split("::").last.downcase.id %}
|
||||
{% info_annos = @type.class.methods.select(&.annotation(::CliGenerator::SubCommand)).map(&.annotation(::CliGenerator::SubCommand)) %}
|
||||
{% examples = [] of StringLiteral %}
|
||||
{% info_annos.select(&.[](:examples)).map(&.[](:examples).resolve).each(&.each{|example| examples << example}) %}
|
||||
HEADER = [
|
||||
"#{PROGRAM_NAME} {{name}} [[flags]]",
|
||||
"",
|
||||
{% unless info_annos.empty? %}
|
||||
{% unless examples.empty? %}
|
||||
"Examples:".colorize(:green),
|
||||
"-------------------------------------------------------------------------------".colorize(:blue),
|
||||
{% for anno in info_annos %}
|
||||
{% examples = anno[:examples].resolve %}
|
||||
{% for example in examples %}
|
||||
{{example}},
|
||||
{% end %}
|
||||
{% for example in examples %}
|
||||
{{example}},
|
||||
{% end %}
|
||||
{% end %}
|
||||
].join("\n")
|
||||
@@ -79,7 +78,7 @@ module CliGenerator
|
||||
end
|
||||
{% end %}
|
||||
|
||||
@[CommandArgument(type: {{type}}, short: {{short}}, long: {{long}}, description: {{description}})]
|
||||
@[::CliGenerator::CommandArgument(type: {{type}}, short: {{short}}, long: {{long}}, description: {{description}})]
|
||||
def self.{{arg_name}}(var : String) : Nil
|
||||
{% if check %}
|
||||
## If the check exists go ahead and call it
|
||||
|
||||
Reference in New Issue
Block a user