Doing test

This commit is contained in:
Tristan Ancelet
2026-02-23 15:22:13 -06:00
parent 5a14063e1f
commit 21a2b0d972
3 changed files with 29 additions and 25 deletions

View File

@@ -21,7 +21,6 @@ module CliGen
class Command
extend CliGen::Parser
@@action : String = ""
macro inherited
macro finished
@@ -29,10 +28,12 @@ module CliGen
define_header
define_runner
define_parser
define_action_setter
end
end
macro define_actions
@@action : String = ""
ACTIONS = {{@type.class.methods.select(&.annotation(::CliGen::SubCommand)).map(&.name.stringify)}} of String
end
@@ -42,7 +43,7 @@ module CliGen
{% examples = [] of StringLiteral %}
{% info_annos.select(&.[](:examples)).map(&.[](:examples).resolve).each(&.each{|example| examples << example}) %}
HEADER = [
"#{PROGRAM_NAME} {{name}} [[flags]]",
"#{CliGen::APPNAME} {{name}} [[flags]]",
"",
{% unless examples.empty? %}
"Examples:".colorize(:green),
@@ -140,15 +141,17 @@ module CliGen
{{method.name}}
{% end %}
else
abort "ERROR : No action provided to command #{@type.name}"
abort "ERROR : No action provided to command {{@type.name}}"
end
{% end %}
end
end
def self.action=(action : String)
abort "ERROR : Action(#{action}) is not valid. Only #{ACTIONS.join(", ")} are acceptable" unless ACTIONS.includes?(action)
@@action = action
macro define_action_setter
def self.action=(action : String)
abort "ERROR : Action(#{action}) is not valid. Only #{ACTIONS.join(", ")} are acceptable" unless ACTIONS.includes?(action)
@@action = action
end
end
end