Compare commits

...

2 Commits

Author SHA1 Message Date
Tristan Ancelet 1085335c88 Had to add for lib setup 2026-08-11 11:22:02 -05:00
Tristan Ancelet 19ea00ef72 added a few things 2026-08-11 11:17:34 -05:00
6 changed files with 16 additions and 10 deletions
+2
View File
@@ -1,5 +1,7 @@
*
!CLAUDE.md
!lib/
!lib/cligen
!src/
!src/**
!shard.yml
Symlink
+1
View File
@@ -0,0 +1 @@
../src/
+4
View File
@@ -28,6 +28,10 @@ module CliGen
@{{var.id}} = {{var.default_value}}
{% end %}
{% end %}
{% if @type.has_method? :after_initialize %}
after_initialize
{% end %}
{% end %}
end
end
+4 -3
View File
@@ -154,7 +154,7 @@ module CliGen
ECR.render({{CliGen::HELP_OVERRIDE_TEMPLATE}})
{% else %}
{% puts "No type overrided help output. Using default" if env("DEBUG") %}
ECR.render("src/cligen/template/cmd_help.ecr")
ECR.render("lib/cligen/cligen/template/cmd_help.ecr")
{% end %} # otherwise
{% debug if env("DEBUG") %}
{% end %}
@@ -235,7 +235,7 @@ module CliGen
end
when MatchType::NoMatch
raise "ERROR : CommandNode(#{@name}).process : No command, subcommand or flag match for '#{arg.value}'"
abort "ERROR : CommandNode(#{@name}).process : No command, subcommand or flag match for '#{arg.value}'"
end
end
@@ -255,7 +255,8 @@ module CliGen
{% if T.has_method?(:main) %}
cls.main
{% else %}
raise "ERROR : CommandNode({{T}})\#{{@def.name}} : No subcommand matched and no #main defined"
abort help
#raise "ERROR : CommandNode({{T}})\#{{@def.name}} : No subcommand matched and no #main defined"
{% end %}
end
{% end %}
+4 -6
View File
@@ -61,12 +61,10 @@ module CliGen
def process(argv : Array(Arg) = [] of Arg) : Nil
if requires_arg?
raise "ERROR : Flag({{T}}) : Array requires an argument but provided array is empty" if argv.empty?
raise "ERROR : Flag(#{T}, long: #{@long_key}) : Array requires an argument but provided array is empty" if argv.empty?
abort "ERROR : Flag(#{T}, long: #{@long_key}) : Provided argument was a flag (#{argv.first.value})" if argv.first.flag?
end
if argv.first.flag?
abort "ERROR : Flag({{T}}) : Provided argument was a flag (#{argv.first.value})"
end
{% if T == Bool %}
@value = true
@@ -101,7 +99,7 @@ module CliGen
{% elsif T == String %} # String
@value = argv.first.value
argv.first.processed
{% elsif T.class < CliGen::Parseable %}
{% elsif T.class < CliGen::Parsable %}
processed = argv.select(&.processed?)
@value = T.parse_args(argv)
post_processed = argv.select(&.processed?)
@@ -109,7 +107,7 @@ module CliGen
raise "ERROR : Flag({{T}}, long: #{@long_key})#process : Your {{T}}#process_args did not mark processed args as processed. Please check your code"
end
{% else %}
{% raise "ERROR : Flag({{T}}#process : Generic Type #{T} is not supported. To add support you must include CliGen::Parsable & implement the class method" %}
{% raise "ERROR : Flag({{T}}#process : Generic Type #{T} is not supported. To add support you must extend with CliGen::Parsable & implement the class method" %}
{% end %}
validate!
+1 -1
View File
@@ -1,3 +1,3 @@
module CliGen::Parseable
module CliGen::Parsable
abstract def parse_args(args : Array(CliGen::Arg))
end