Added prerun command annotation & implementation

This commit is contained in:
Tristan Ancelet
2026-08-11 11:37:22 -05:00
parent 4af08f8efe
commit 8447a1ffbb
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -14,6 +14,9 @@ module CliGen
annotation Selection annotation Selection
end end
annotation PreRunCommand
end
annotation SubCommand annotation SubCommand
end end
end end
+4
View File
@@ -244,6 +244,10 @@ module CliGen
{% unless T == Nil %} {% unless T == Nil %}
unless passed_execution unless passed_execution
cls = T.new(handler: self.as(CliGen::BaseCommandNode)) cls = T.new(handler: self.as(CliGen::BaseCommandNode))
{% prerun = T.methods.select(&.annotation(CliGen::PreRunCommand)) %}
{% for cmd in prerun %}
cls.{{cmd.name}}
{% end %}
{% subcmds = T.methods.select(&.annotation(CliGen::SubCommand)) %} {% subcmds = T.methods.select(&.annotation(CliGen::SubCommand)) %}
{% begin %} {% begin %}
case matched_subcommand case matched_subcommand