From 18c5a559b126b12e69e6396cb80678c91c37a5d9 Mon Sep 17 00:00:00 2001 From: Tristan Ancelet Date: Wed, 12 Aug 2026 13:08:24 -0500 Subject: [PATCH] Added exit & default to help if no main is specified --- src/cligen/command_node.cr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cligen/command_node.cr b/src/cligen/command_node.cr index 58301c3..7d832d2 100644 --- a/src/cligen/command_node.cr +++ b/src/cligen/command_node.cr @@ -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