diff --git a/spec/clim/compile_time_error_spec/files/main_command_default_help.cr b/spec/clim/compile_time_error_spec/files/main_command_default_help.cr new file mode 100644 index 00000000..5bbf6ffc --- /dev/null +++ b/spec/clim/compile_time_error_spec/files/main_command_default_help.cr @@ -0,0 +1,22 @@ +require "./../../../../src/clim" + +class MyCli < Clim + main_command do + run do |opts, args| + end + sub_command "sub_command" do + desc "sub_comand." + option "-n NUM", type: Int32, desc: "Number.", default: 0 + run do |opts, args| + end + sub_command "sub_sub_command" do + desc "sub_sub_comand description." + option "-p PASSWORD", type: String, desc: "Password.", required: true + run do |opts, args| + end + end + end + end +end + +MyCli.start(ARGV) diff --git a/spec/clim/compile_time_error_spec/stdout_spec.cr b/spec/clim/compile_time_error_spec/stdout_spec.cr index c0347e20..f474d77a 100644 --- a/spec/clim/compile_time_error_spec/stdout_spec.cr +++ b/spec/clim/compile_time_error_spec/stdout_spec.cr @@ -15,6 +15,27 @@ describe "STDOUT spec, " do sub_sub_command sub_sub_comand description. + DISPLAY + end + it "display main_command help." do + `crystal run spec/clim/compile_time_error_spec/files/main_command_default_help.cr --no-color -- sub_command --help`.should eq <<-DISPLAY + + sub_comand. + + Usage: + + sub_command [options] [arguments] + + Options: + + -n NUM Number. [type:Int32] [default:0] + --help Show this help. + + Sub Commands: + + sub_sub_command sub_sub_comand description. + + DISPLAY end end