Changing to cligen

This commit is contained in:
Tristan Ancelet
2026-02-23 13:08:56 -06:00
parent 9b50633c0e
commit 136298e67c
7 changed files with 32 additions and 32 deletions

View File

@@ -1,8 +1,8 @@
require "spec"
require "../src/command"
@[CliGenerator::CommandInfo(description: "Test")]
class CommandSubclass < CliGenerator::Command
@[CliGen::CommandInfo(description: "Test")]
class CommandSubclass < CliGen::Command
define_argument(testvar,
type: Int32,
@@ -22,19 +22,19 @@ EXAMPLES = [
"Have test"
]
@[CliGenerator::SubCommand(description: "test", examples: ::EXAMPLES)]
@[CliGen::SubCommand(description: "test", examples: ::EXAMPLES)]
def CommandSubclass.do_thing
puts "HI"
end
@[CliGenerator::CommandPreRun]
@[CliGen::CommandPreRun]
def CommandSubclass.check_things
puts "I was run"
end
## Need to make sure EVERYTHING is generated before testing
macro finished
describe CliGenerator::Command do
describe CliGen::Command do
describe "subclassing" do
@@ -57,7 +57,7 @@ describe CliGenerator::Command do
CommandSubclass::HEADER.includes?("Examples").should be_true
end
{% pre_runs = CommandSubclass.class.methods.select(&.annotation(::CliGenerator::CommandPreRun)) %}
{% pre_runs = CommandSubclass.class.methods.select(&.annotation(::CliGen::CommandPreRun)) %}
{% run = CommandSubclass.class.methods.find{|m| m.name.stringify == "run"}.stringify %}
{% if pre_runs.size > 0 %}
describe "when defining pre-run methods" do
@@ -69,7 +69,7 @@ describe CliGenerator::Command do
end
{% end %}
{% subcommands = CommandSubclass.class.methods.select(&.annotation(::CliGenerator::SubCommand)) %}
{% subcommands = CommandSubclass.class.methods.select(&.annotation(::CliGen::SubCommand)) %}
{% unless subcommands.empty? %}
describe "should have subcommands" do
{% for subcommand in subcommands %}
@@ -79,7 +79,7 @@ describe CliGenerator::Command do
{% end %}
end
{% end %}
{% arguments = CommandSubclass.class.methods.select(&.annotation(::CliGenerator::CommandArgument)) %}
{% arguments = CommandSubclass.class.methods.select(&.annotation(::CliGen::CommandArgument)) %}
{% unless arguments.empty? %}
describe "should have arguments" do
{% for argument in arguments %}
@@ -105,7 +105,7 @@ describe CliGenerator::Command do
{% unless arguments.empty? %}
describe "for arguments" do
{% for argument in arguments %}
{% anno = argument.annotation(::CliGenerator::CommandArgument) %}
{% anno = argument.annotation(::CliGen::CommandArgument) %}
it "has " + {{anno[:long].stringify}} do
{{make_parser}}.includes?({{anno[:long]}}).should be_true
end