Added exit & default to help if no main is specified

This commit is contained in:
Tristan Ancelet
2026-08-12 13:08:24 -05:00
parent 28c45fae9e
commit 18c5a559b1
+7 -2
View File
@@ -187,6 +187,7 @@ module CliGen
{% for cls in CliGen::Command.subclasses %}
when CliGen::CommandNode({{cls.name}})
match.as(CommandNode({{cls}})).process(args.reject(&.processed?))
exit 0
{% end %}
else
raise "ERROR : Couldn't find thing"
@@ -259,12 +260,16 @@ module CliGen
{% if T.has_method?(:main) %}
cls.main
{% else %}
abort help
#raise "ERROR : CommandNode({{T}})\#{{@def.name}} : No subcommand matched and no #main defined"
puts help
puts "ERROR : CommandNode({{T}})\#{{@def.name}} : No subcommand matched and no #main defined"
{% end %}
exit 0
end
{% end %}
end
{% else %}
puts self.as(Nil).help
exit 0
{% end %}
end
end