Added exit & default to help if no main is specified
This commit is contained in:
@@ -187,6 +187,7 @@ module CliGen
|
|||||||
{% for cls in CliGen::Command.subclasses %}
|
{% for cls in CliGen::Command.subclasses %}
|
||||||
when CliGen::CommandNode({{cls.name}})
|
when CliGen::CommandNode({{cls.name}})
|
||||||
match.as(CommandNode({{cls}})).process(args.reject(&.processed?))
|
match.as(CommandNode({{cls}})).process(args.reject(&.processed?))
|
||||||
|
exit 0
|
||||||
{% end %}
|
{% end %}
|
||||||
else
|
else
|
||||||
raise "ERROR : Couldn't find thing"
|
raise "ERROR : Couldn't find thing"
|
||||||
@@ -259,12 +260,16 @@ module CliGen
|
|||||||
{% if T.has_method?(:main) %}
|
{% if T.has_method?(:main) %}
|
||||||
cls.main
|
cls.main
|
||||||
{% else %}
|
{% else %}
|
||||||
abort help
|
puts help
|
||||||
#raise "ERROR : CommandNode({{T}})\#{{@def.name}} : No subcommand matched and no #main defined"
|
puts "ERROR : CommandNode({{T}})\#{{@def.name}} : No subcommand matched and no #main defined"
|
||||||
{% end %}
|
{% end %}
|
||||||
|
exit 0
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
{% else %}
|
||||||
|
puts self.as(Nil).help
|
||||||
|
exit 0
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user