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
65e690b
commit fcab3fd
Showing
13 changed files
with
1,676 additions
and
1,665 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,227 @@ | ||
require "../dsl_spec" | ||
|
||
{% begin %} | ||
{% | ||
main_help_message = <<-HELP_MESSAGE | ||
Command Line Interface Tool. | ||
Usage: | ||
main_command_of_clim_library [options] [arguments] | ||
Options: | ||
-b ARG, --bool=ARG Bool option description. [type:Bool] [default:false] | ||
--help Show this help. | ||
HELP_MESSAGE | ||
%} | ||
|
||
spec( | ||
spec_class_name: MainCommandWithBoolArgumentsRequiredFalseAndDefaultExists, | ||
spec_dsl_lines: [ | ||
"option \"-b ARG\", \"--bool=ARG\", type: Bool, desc: \"Bool option description.\", required: false, default: false", | ||
], | ||
spec_desc: "main command with Bool option,", | ||
spec_cases: [ | ||
{ | ||
argv: [] of String, | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["-b", "true"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-b", "true", "arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["arg1", "-b", "true"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["-b", "false"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-b", "false", "arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["arg1", "-b", "false"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["--bool", "true"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["--bool", "true", "arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["arg1", "--bool", "true"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["--bool", "false"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["--bool", "false", "arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["arg1", "--bool", "false"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
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: ["-b"], | ||
exception_message: "Option that requires an argument. \"-b\"", | ||
}, | ||
{ | ||
argv: ["--bool"], | ||
exception_message: "Option that requires an argument. \"--bool\"", | ||
}, | ||
{ | ||
argv: ["arg1", "-b"], | ||
exception_message: "Option that requires an argument. \"-b\"", | ||
}, | ||
{ | ||
argv: ["arg1", "--bool"], | ||
exception_message: "Option that requires an argument. \"--bool\"", | ||
}, | ||
{ | ||
argv: ["-b", "arg1"], | ||
exception_message: "Bool arguments accept only \"true\" or \"false\". Input: [arg1]", | ||
}, | ||
{ | ||
argv: ["--bool=arg1"], | ||
exception_message: "Bool arguments accept only \"true\" or \"false\". Input: [arg1]", | ||
}, | ||
{ | ||
argv: ["--b"], | ||
exception_message: "Undefined option. \"--b\"", | ||
}, | ||
{ | ||
argv: ["-bool"], | ||
exception_message: "Bool arguments accept only \"true\" or \"false\". Input: [ool]", | ||
}, | ||
{ | ||
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,123 @@ | ||
require "../dsl_spec" | ||
|
||
{% begin %} | ||
{% | ||
main_help_message = <<-HELP_MESSAGE | ||
Command Line Interface Tool. | ||
Usage: | ||
main_command_of_clim_library [options] [arguments] | ||
Options: | ||
-b, --bool Bool option description. [type:Bool] | ||
--help Show this help. | ||
HELP_MESSAGE | ||
%} | ||
|
||
spec( | ||
spec_class_name: MainCommandWithBoolRequiredFalseOnly, | ||
spec_dsl_lines: [ | ||
"option \"-b\", \"--bool\", type: Bool, desc: \"Bool option description.\", required: false", | ||
], | ||
spec_desc: "main command with Bool option,", | ||
spec_cases: [ | ||
{ | ||
argv: [] of String, | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => false, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["-b"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["--bool"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: [] of String, | ||
}, | ||
{ | ||
argv: ["-b", "arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["arg1", "-b"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["--bool", "arg1"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
argv: ["arg1", "--bool"], | ||
expect_help: {{main_help_message}}, | ||
expect_opts: { | ||
"type" => Bool, | ||
"method" => "bool", | ||
"expect_value" => true, | ||
}, | ||
expect_args: ["arg1"], | ||
}, | ||
{ | ||
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.