From 0d654acce353a39d878efee9cb22c0fa1a74b9e5 Mon Sep 17 00:00:00 2001 From: at-grandpa Date: Sat, 17 Mar 2018 18:25:00 +0900 Subject: [PATCH] fix --- spec/clim/dsl_spec/main_command_spec.cr | 60 +++++++++++++++++++++++++ src/clim/command.cr | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/spec/clim/dsl_spec/main_command_spec.cr b/spec/clim/dsl_spec/main_command_spec.cr index c6c3b9da..1c6cf79d 100644 --- a/spec/clim/dsl_spec/main_command_spec.cr +++ b/spec/clim/dsl_spec/main_command_spec.cr @@ -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 diff --git a/src/clim/command.cr b/src/clim/command.cr index b517a581..4cbb6a57 100644 --- a/src/clim/command.cr +++ b/src/clim/command.cr @@ -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)