Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
at-grandpa committed Dec 25, 2018
1 parent 65e690b commit fcab3fd
Show file tree
Hide file tree
Showing 13 changed files with 1,676 additions and 1,665 deletions.
227 changes: 227 additions & 0 deletions spec/clim/dsl_spec/bool_10_spec.cr
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 %}
123 changes: 123 additions & 0 deletions spec/clim/dsl_spec/bool_11_spec.cr
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 %}
Loading

0 comments on commit fcab3fd

Please sign in to comment.