Skip to content

Commit

Permalink
Merge pull request #42 from at-grandpa/crystal-version-0.30.0
Browse files Browse the repository at this point in the history
crystal version 0.30.0
  • Loading branch information
at-grandpa authored Aug 7, 2019
2 parents db031a6 + f550938 commit a07bd37
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 63 deletions.
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Add this to your application's `shard.yml`:
dependencies:
clim:
github: at-grandpa/clim
version: 0.7.0
version: 0.8.0
```
## Minimum sample
Expand Down Expand Up @@ -342,14 +342,14 @@ mycli version: 1.0.1

You can specify multiple options for the command.

Argument | Description | Example | Required | Default
---------|----------|---------|------|------
First argument | short or long name | `-t TIMES`, `--times TIMES` | true | -
Second argument | long name | `--times TIMES` | false | -
`type` | option type | `type: Array(Float32)` | false | `String`
`desc` | option description | `desc: "option description."` | false | `"Option description."`
`default` | default value | `default: [1.1_f32, 2.2_f32]` | false | `nil`
`required` | required flag | `required: true` | false | `false`
| Argument | Description | Example | Required | Default |
| --------------- | ------------------ | ----------------------------- | -------- | ----------------------- |
| First argument | short or long name | `-t TIMES`, `--times TIMES` | true | - |
| Second argument | long name | `--times TIMES` | false | - |
| `type` | option type | `type: Array(Float32)` | false | `String` |
| `desc` | option description | `desc: "option description."` | false | `"Option description."` |
| `default` | default value | `default: [1.1_f32, 2.2_f32]` | false | `nil` |
| `required` | required flag | `required: true` | false | `false` |

```crystal
class MyCli < Clim
Expand All @@ -370,39 +370,39 @@ The type of the option is determined by the `default` and `required` patterns.

For example `Int8`.

`default` | `required` | Type
---------|----------|---------
exist | `true` | `Int8` (default: Your specified value.) |
exist | `false` | `Int8` (default: Your specified value.) |
not exist | `true` | `Int8` |
not exist | `false` | `Int8 \| Nil` |
| `default` | `required` | Type |
| --------- | ---------- | --------------------------------------- |
| exist | `true` | `Int8` (default: Your specified value.) |
| exist | `false` | `Int8` (default: Your specified value.) |
| not exist | `true` | `Int8` |
| not exist | `false` | `Int8 \| Nil` |

*String*

`default` | `required` | Type
---------|----------|---------
exist | `true` | `String` (default: Your specified value.) |
exist | `false` | `String` (default: Your specified value.) |
not exist | `true` | `String` |
not exist | `false` | `String \| Nil` |
| `default` | `required` | Type |
| --------- | ---------- | ----------------------------------------- |
| exist | `true` | `String` (default: Your specified value.) |
| exist | `false` | `String` (default: Your specified value.) |
| not exist | `true` | `String` |
| not exist | `false` | `String \| Nil` |

*Bool*

`default` | `required` | Type
---------|----------|---------
exist | `true` | `Bool` (default: Your specified value.) |
exist | `false` | `Bool` (default: Your specified value.) |
not exist | `true` | `Bool` |
not exist | `false` | `Bool` (default: `false`) |
| `default` | `required` | Type |
| --------- | ---------- | --------------------------------------- |
| exist | `true` | `Bool` (default: Your specified value.) |
| exist | `false` | `Bool` (default: Your specified value.) |
| not exist | `true` | `Bool` |
| not exist | `false` | `Bool` (default: `false`) |

*Array*

`default` | `required` | Type
---------|----------|---------
exist | `true` | `Array(T)` (default: Your specified value.) |
exist | `false` | `Array(T)` (default: Your specified value.) |
not exist | `true` | `Array(T)` |
not exist | `false` | `Array(T)` (default: `[] of T`) |
| `default` | `required` | Type |
| --------- | ---------- | ------------------------------------------- |
| exist | `true` | `Array(T)` (default: Your specified value.) |
| exist | `false` | `Array(T)` (default: Your specified value.) |
| not exist | `true` | `Array(T)` |
| not exist | `false` | `Array(T)` (default: `[] of T`) |

For Bool, you do not need to specify arguments for short or long.

Expand Down
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: clim
version: 0.7.0
version: 0.8.0

authors:
- at-grandpa <@at_grandpa>
Expand All @@ -8,6 +8,6 @@ targets:
clim:
main: src/clim.cr

crystal: 0.29.0
crystal: 0.30.0

license: MIT
72 changes: 45 additions & 27 deletions spec/clim/compile_time_error_spec/compile_time_error_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,91 +3,109 @@ require "./../../spec_helper"
describe "Compile time spec, " do
it "Bool with 'required true'." do
`crystal run spec/clim/compile_time_error_spec/files/bool_with_required_true.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/bool_with_required_true.cr:6: You can not specify 'required: true' for Bool option.
Showing last frame. Use --error-trace for full trace.
option "-b", type: Bool, desc: "your bool.", required: true
^
In spec/clim/compile_time_error_spec/files/bool_with_required_true.cr:6:5
6 | option \"-b\", type: Bool, desc: \"your bool.\", required: true
^
Error: You can not specify 'required: true' for Bool option.
ERROR
end
it "duplicate 'main_command'." do
`crystal run spec/clim/compile_time_error_spec/files/duplicate_main_command.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/duplicate_main_command.cr:9: Main command is already defined.
Showing last frame. Use --error-trace for full trace.
main_command do
^~~~~~~~~~~~
In spec/clim/compile_time_error_spec/files/duplicate_main_command.cr:9:3
9 | main_command do
^-----------
Error: Main command is already defined.
ERROR
end
it "duplicate 'sub_command'." do
`crystal run spec/clim/compile_time_error_spec/files/duplicate_sub_command.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/duplicate_sub_command.cr:12: Command "sub_command" is already defined.
Showing last frame. Use --error-trace for full trace.
command "sub_command" do
^~~~~~~
In spec/clim/compile_time_error_spec/files/duplicate_sub_command.cr:12:5
12 | command \"sub_command\" do
^------
Error: Command \"sub_command\" is already defined.
ERROR
end
it "duplicate 'main_command' in sub command." do
`crystal run spec/clim/compile_time_error_spec/files/duplicate_main_command_in_sub_command.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/duplicate_main_command_in_sub_command.cr:7: Can not be declared 'main_command' or 'main' as sub command.
Showing last frame. Use --error-trace for full trace.
main_command do
^~~~~~~~~~~~
In spec/clim/compile_time_error_spec/files/duplicate_main_command_in_sub_command.cr:7:5
7 | main_command do
^-----------
Error: Can not be declared 'main_command' or 'main' as sub command.
ERROR
end
it "'main_command' is not defined." do
`crystal run spec/clim/compile_time_error_spec/files/main_command_is_not_defined.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/main_command_is_not_defined.cr:4: undefined local variable or method 'sub_command' for MyCli.class
Showing last frame. Use --error-trace for full trace.
sub_command do
^~~~~~~~~~~
In spec/clim/compile_time_error_spec/files/main_command_is_not_defined.cr:4:3
4 | sub_command do
^----------
Error: undefined local variable or method 'sub_command' for MyCli.class
ERROR
end
it "'main_command' with alias name." do
`crystal run spec/clim/compile_time_error_spec/files/main_command_with_alias_name.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/main_command_with_alias_name.cr:5: 'alias_name' is not supported on main command.
Showing last frame. Use --error-trace for full trace.
alias_name "main2"
^~~~~~~~~~
In spec/clim/compile_time_error_spec/files/main_command_with_alias_name.cr:5:5
5 | alias_name \"main2\"
^---------
Error: 'alias_name' is not supported on main command.
ERROR
end
it "not supported type." do
`crystal run spec/clim/compile_time_error_spec/files/not_supported_type.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/not_supported_type.cr:6: Type [BigInt] is not supported on option.
Showing last frame. Use --error-trace for full trace.
option "-n", type: BigInt, desc: "my big int.", default: 0
^
In spec/clim/compile_time_error_spec/files/not_supported_type.cr:6:5
6 | option \"-n\", type: BigInt, desc: \"my big int.\", default: 0
^
Error: Type [BigInt] is not supported on option.
ERROR
end
it "empty option name." do
`crystal run spec/clim/compile_time_error_spec/files/empty_option_name.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/empty_option_name.cr:6: Empty option name.
Showing last frame. Use --error-trace for full trace.
option "", type: String, desc: "empty option name."
^
In spec/clim/compile_time_error_spec/files/empty_option_name.cr:6:5
6 | option \"\", type: String, desc: \"empty option name.\"
^
Error: Empty option name.
ERROR
end
it "help_template in sub_command." do
`crystal run spec/clim/compile_time_error_spec/files/sub_command_with_help_template.cr --no-color 2>&1`.should eq <<-ERROR
Error in spec/clim/compile_time_error_spec/files/sub_command_with_help_template.cr:8: Can not be declared 'help_template' as sub command.
Showing last frame. Use --error-trace for full trace.
help_template do |desc, usage, options, sub_commands|
^~~~~~~~~~~~~
In spec/clim/compile_time_error_spec/files/sub_command_with_help_template.cr:8:7
8 | help_template do |desc, usage, options, sub_commands|
^------------
Error: Can not be declared 'help_template' as sub command.
ERROR
end
Expand Down
2 changes: 1 addition & 1 deletion src/clim/version.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Clim
VERSION = "0.7.0"
VERSION = "0.8.0"
end

0 comments on commit a07bd37

Please sign in to comment.