diff --git a/src/cligen/annotations.cr b/src/cligen/annotations.cr index bf331ec..478ac9a 100644 --- a/src/cligen/annotations.cr +++ b/src/cligen/annotations.cr @@ -14,6 +14,9 @@ module CliGen annotation Selection end + annotation PreRunCommand + end + annotation SubCommand end end diff --git a/src/cligen/command_node.cr b/src/cligen/command_node.cr index b7536bb..58301c3 100644 --- a/src/cligen/command_node.cr +++ b/src/cligen/command_node.cr @@ -244,6 +244,10 @@ module CliGen {% unless T == Nil %} unless passed_execution 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)) %} {% begin %} case matched_subcommand