Skip to content

Commit

Permalink
Merge pull request #24 from at-grandpa/fix-version-macro
Browse files Browse the repository at this point in the history
fix version macro
  • Loading branch information
at-grandpa authored Mar 17, 2018
2 parents 31fc594 + 0d654ac commit 8a5598b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
60 changes: 60 additions & 0 deletions spec/clim/dsl_spec/main_command_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,66 @@ spec(
)
{% end %}

{% begin %}
{%
main_help_message = <<-HELP_MESSAGE
Main command with desc.
Usage:
main_command with usage [options] [arguments]
Options:
--help Show this help.
--version Show version.
HELP_MESSAGE
%}

spec(
spec_class_name: MainCommandWithVersionConst,
spec_dsl_lines: [
"version Clim::VERSION",
"desc \"Main command with desc.\"",
"usage \"main_command with usage [options] [arguments]\"",
],
spec_desc: "main command,",
spec_cases: [
{
argv: ["--help"],
expect_help: {{main_help_message}},
},
{
argv: ["--help", "ignore-arg"],
expect_help: {{main_help_message}},
},
{
argv: ["ignore-arg", "--help"],
expect_help: {{main_help_message}},
},
{
argv: ["--version"],
expect_output: Clim::VERSION + "\n",
},
{
argv: ["--version", "arg"],
expect_output: Clim::VERSION + "\n",
},
{
argv: ["arg", "--version"],
expect_output: Clim::VERSION + "\n",
},
{
argv: ["-v"],
exception_message: "Undefined option. \"-v\"",
},
]
)
{% end %}

{% begin %}
{%
main_help_message = <<-HELP_MESSAGE
Expand Down
2 changes: 1 addition & 1 deletion src/clim/command.cr
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Clim

macro version(version_str, short = nil)
def version_str : String
{{ version_str.id.stringify }}
{{ version_str }}
end

def define_version(parser)
Expand Down

0 comments on commit 8a5598b

Please sign in to comment.