Skip to content

Commit 8953f73

Browse files
committed
unknown model item
1 parent e33a33e commit 8953f73

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

shard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cli
2-
version: 0.6.4
2+
version: 0.6.5
33

44
authors:
55
- mosop
@@ -9,7 +9,7 @@ crystal: 0.20.5
99
dependencies:
1010
optarg:
1111
github: mosop/optarg
12-
version: ~> 0.5.4
12+
version: ~> 0.5.5
1313
string_inflection:
1414
github: mosop/string_inflection
1515
version: ~> 0.2.0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require "../spec_helper"
2+
3+
module CliInternalSpecs::UnknownOptionModelItem
4+
class Command < Cli::Command
5+
class Options
6+
string "-s"
7+
unknown
8+
end
9+
10+
def run
11+
puts options.s?
12+
puts unparsed_args.join(" ")
13+
end
14+
end
15+
16+
it name do
17+
Command.run(%w(foo bar baz)) do |cmd|
18+
cmd.out.gets_to_end.chomp.should eq "\nfoo bar baz"
19+
end
20+
Command.run(%w(-s foo bar baz)) do |cmd|
21+
cmd.out.gets_to_end.chomp.should eq "foo\nbar baz"
22+
end
23+
end
24+
end

src/lib/option_model/dsl.cr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class Cli::OptionModel
6565
::Optarg::Model.on({{names}}, metadata: ::Cli::OptionMetadata.new(description: {{desc}})) {{block}}
6666
end
6767

68+
# Defines an unknown model item.
69+
macro unknown(desc = nil, &block)
70+
::Optarg::Model.unknown(metadata: ::Cli::OptionMetadata.new(description: {{desc}})) {{block}}
71+
end
72+
6873
# Defines a handler model item for printing a help message.
6974
macro help(names = nil, desc = nil)
7075
{%

src/version.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Cli
2-
VERSION = "0.6.4"
2+
VERSION = "0.6.5"
33
end

0 commit comments

Comments
 (0)