forked from at-grandpa/clim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fcab3fd
commit 56314ec
Showing
14 changed files
with
2,056 additions
and
2,014 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
require "../dsl_spec" | ||
|
||
{% begin %} | ||
{% | ||
main_help_message = <<-HELP_MESSAGE | ||
Command Line Interface Tool. | ||
Usage: | ||
main_command_of_clim_library [options] [arguments] | ||
Options: | ||
-s ARG, --string=ARG Option description. [type:String] | ||
--help Show this help. | ||
HELP_MESSAGE | ||
%} | ||
|
||
spec( | ||
spec_class_name: MainCommandWithString, | ||
spec_dsl_lines: [ | ||
"option \"-s ARG\", \"--string=ARG\", type: String", | ||
], | ||
spec_desc: "main command with String options,", | ||
spec_cases: [ | ||
{ | ||
argv: [] of String, | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => nil, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => nil, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["-s", "string1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-sstring1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["--string", "string1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["--string=string1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-s", "string1", "arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["arg1", "-s", "string1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["-string"], # Unintended case. | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => "tring", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-s=string1"], # Unintended case. | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "string", | ||
"expect_value" => "=string1", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-h"], | ||
exception_message: "Undefined option. \"-h\"", | ||
}, | ||
{ | ||
argv: ["--help", "-ignore-option"], | ||
exception_message: "Undefined option. \"-ignore-option\"", | ||
}, | ||
{ | ||
argv: ["-ignore-option", "--help"], | ||
exception_message: "Undefined option. \"-ignore-option\"", | ||
}, | ||
{ | ||
argv: ["-s"], | ||
exception_message: "Option that requires an argument. \"-s\"", | ||
}, | ||
{ | ||
argv: ["--string"], | ||
exception_message: "Option that requires an argument. \"--string\"", | ||
}, | ||
{ | ||
argv: ["arg1", "-s"], | ||
exception_message: "Option that requires an argument. \"-s\"", | ||
}, | ||
{ | ||
argv: ["arg1", "--string"], | ||
exception_message: "Option that requires an argument. \"--string\"", | ||
}, | ||
{ | ||
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}}, | ||
}, | ||
] | ||
) | ||
{% end %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
require "../dsl_spec" | ||
|
||
{% begin %} | ||
{% | ||
main_help_message = <<-HELP_MESSAGE | ||
Command Line Interface Tool. | ||
Usage: | ||
main_command_of_clim_library [options] [arguments] | ||
Options: | ||
-s ARG Option description. [type:String] | ||
--help Show this help. | ||
HELP_MESSAGE | ||
%} | ||
|
||
spec( | ||
spec_class_name: MainCommandWithStringOnlyShortOption, | ||
spec_dsl_lines: [ | ||
"option \"-s ARG\", type: String", | ||
], | ||
spec_desc: "main command with String options,", | ||
spec_cases: [ | ||
{ | ||
argv: [] of String, | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "s", | ||
"expect_value" => nil, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "s", | ||
"expect_value" => nil, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["-s", "string1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "s", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-sstring1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "s", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-s", "string1", "arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "s", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["arg1", "-s", "string1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "s", | ||
"expect_value" => "string1", | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["-string"], # Unintended case. | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "s", | ||
"expect_value" => "tring", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-s=string1"], # Unintended case. | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => String?, | ||
"method" => "s", | ||
"expect_value" => "=string1", | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-h"], | ||
exception_message: "Undefined option. \"-h\"", | ||
}, | ||
{ | ||
argv: ["--help", "-ignore-option"], | ||
exception_message: "Undefined option. \"-ignore-option\"", | ||
}, | ||
{ | ||
argv: ["-ignore-option", "--help"], | ||
exception_message: "Undefined option. \"-ignore-option\"", | ||
}, | ||
{ | ||
argv: ["-s"], | ||
exception_message: "Option that requires an argument. \"-s\"", | ||
}, | ||
{ | ||
argv: ["--string"], | ||
exception_message: "Undefined option. \"--string\"", | ||
}, | ||
{ | ||
argv: ["--string", "string1"], | ||
exception_message: "Undefined option. \"--string\"", | ||
}, | ||
{ | ||
argv: ["--string=string1"], | ||
exception_message: "Undefined option. \"--string=string1\"", | ||
}, | ||
{ | ||
argv: ["arg1", "-s"], | ||
exception_message: "Option that requires an argument. \"-s\"", | ||
}, | ||
{ | ||
argv: ["arg1", "--string"], | ||
exception_message: "Undefined option. \"--string\"", | ||
}, | ||
{ | ||
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}}, | ||
}, | ||
] | ||
) | ||
{% end %} |
Oops, something went wrong.