Skip to content

Commit

Permalink
Merge pull request #14 from at-grandpa/refactoring
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
at-grandpa authored Aug 1, 2017
2 parents bc36c3d + 6003524 commit ed77d94
Show file tree
Hide file tree
Showing 16 changed files with 663 additions and 719 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Clim supports the following.
- [x] string
- [x] bool
- [x] array
- [x] Default values for options
- [x] Required flag for options
- [x] Nested sub commands
- [x] `--help` option

Expand Down
50 changes: 0 additions & 50 deletions spec/clim/command_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -84,55 +84,6 @@ describe Clim::Command do
cmd.max_name_length.should eq(0)
end
end
describe "#duplicate_sub_command_name?" do
it "returns false when name not found in sub commands. (The same name as the main command.)" do
main_cmd = Command.new("main_cmd")
main_cmd.duplicate_sub_command_name?("main_cmd").should be_falsey
end
it "returns true when name found in sub commands." do
main_cmd = Command.new("main_cmd")

sub_cmd1 = Command.new("sub_cmd1")
main_cmd.sub_cmds << sub_cmd1
sub_cmd2 = Command.new("sub_cmd2")
main_cmd.sub_cmds << sub_cmd2

main_cmd.duplicate_sub_command_name?("sub_cmd1").should be_truthy
end
it "returns false when name not found in sub commands." do
main_cmd = Command.new("main_cmd")

sub_cmd1 = Command.new("sub_cmd1")
main_cmd.sub_cmds << sub_cmd1
sub_cmd2 = Command.new("sub_cmd2")
main_cmd.sub_cmds << sub_cmd2

main_cmd.duplicate_sub_command_name?("sub_cmd_not_duplicated").should be_falsey
end
it "returns false when name not found in sub commands. (It exists in the sub sub command.)" do
main_cmd = Command.new("main_cmd")

sub_cmd = Command.new("sub_cmd")
main_cmd.sub_cmds << sub_cmd

sub_sub_cmd = Command.new("sub_sub_cmd")
sub_cmd.sub_cmds << sub_sub_cmd

main_cmd.duplicate_sub_command_name?("sub_sub_cmd").should be_falsey
end
it "returns true when name found in sub commands from sub_cmd to sub_sub_cmd." do
main_cmd = Command.new("main_cmd")

sub_cmd = Command.new("sub_cmd")
main_cmd.sub_cmds << sub_cmd

sub_sub_cmd = Command.new("sub_sub_cmd")
sub_cmd.sub_cmds << sub_sub_cmd

sub_cmd.duplicate_sub_command_name?("sub_sub_cmd").should be_truthy
end
end

describe "#add_sub_commands?" do
it "add sub command when command name is not duplicated." do
main_cmd = Command.new("main_cmd")
Expand All @@ -155,7 +106,6 @@ describe Clim::Command do
end
end
end

describe "#parse" do
main_cmd = Command.new("init")
Spec.before_each do
Expand Down
8 changes: 4 additions & 4 deletions spec/clim/dsl_spec.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "./../spec_helper"

def create_values(other : Hash(String, String | Bool | Array(String) | Nil) = {} of String => String | Bool | Array(String) | Nil)
values = Options::Values.new
values.hash.merge!(other)
values.hash
def create_opts_hash(other : Hash(String, String | Bool | Array(String) | Nil) = {} of String => String | Bool | Array(String) | Nil)
hash = Clim::ReturnOptsType.new
hash.merge!(other)
hash
end
Loading

0 comments on commit ed77d94

Please sign in to comment.