slop 3.6.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/LICENSE +1 -1
- data/README.md +179 -131
- data/lib/slop.rb +34 -665
- data/lib/slop/error.rb +20 -0
- data/lib/slop/option.rb +84 -181
- data/lib/slop/options.rb +141 -0
- data/lib/slop/parser.rb +111 -0
- data/lib/slop/result.rb +79 -0
- data/lib/slop/types.rb +52 -0
- data/slop.gemspec +6 -3
- data/test/error_test.rb +31 -0
- data/test/option_test.rb +16 -137
- data/test/options_test.rb +79 -0
- data/test/parser_test.rb +65 -0
- data/test/result_test.rb +85 -0
- data/test/test_helper.rb +6 -0
- data/test/types_test.rb +78 -0
- metadata +30 -21
- data/CHANGES.md +0 -309
- data/lib/slop/commands.rb +0 -196
- data/test/commands_test.rb +0 -26
- data/test/helper.rb +0 -12
- data/test/slop_test.rb +0 -518
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Slop::Options do
|
4
|
+
before do
|
5
|
+
@options = Slop::Options.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#on" do
|
9
|
+
it "defaults to null type" do
|
10
|
+
assert_kind_of Slop::NullOption, @options.on("--foo")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "accepts custom types" do
|
14
|
+
module Slop; class FooOption < Option; end; end
|
15
|
+
assert_kind_of Slop::FooOption, @options.on("--foo", type: :foo)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "adds multiple flags" do
|
19
|
+
option = @options.on("-f", "-F", "--foo")
|
20
|
+
assert_equal %w(-f -F --foo), option.flags
|
21
|
+
end
|
22
|
+
|
23
|
+
it "accepts a trailing description" do
|
24
|
+
option = @options.on("--foo", "fooey")
|
25
|
+
assert_equal "fooey", option.desc
|
26
|
+
end
|
27
|
+
|
28
|
+
it "adds the option" do
|
29
|
+
option = @options.on("--foo")
|
30
|
+
assert_equal [option], @options.to_a
|
31
|
+
end
|
32
|
+
|
33
|
+
it "raises an error when a duplicate flag is used" do
|
34
|
+
@options.on("--foo")
|
35
|
+
assert_raises(ArgumentError) { @options.on("--foo") }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#method_missing" do
|
40
|
+
it "uses the method name as an option type" do
|
41
|
+
option = @options.string("--name")
|
42
|
+
assert_kind_of Slop::StringOption, option
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises if a type doesn't exist" do
|
46
|
+
assert_raises(NoMethodError) { @options.unknown }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#respond_to?" do
|
51
|
+
it "handles custom types" do
|
52
|
+
module Slop; class BarOption < Option; end; end
|
53
|
+
assert @options.respond_to?(:bar)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#to_s" do
|
58
|
+
it "is prefixed with the banner" do
|
59
|
+
assert_match(/^usage/, @options.to_s)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "aligns option strings" do
|
63
|
+
@options.on "-f", "--foo", "fooey"
|
64
|
+
@options.on "-s", "short"
|
65
|
+
assert_match(/^ -f, --foo fooey/, @options.to_s)
|
66
|
+
assert_match(/^ -s short/, @options.to_s)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "can use a custom prefix" do
|
70
|
+
@options.on "-f", "--foo"
|
71
|
+
assert_match(/^ -f, --foo/, @options.to_s(prefix: " "))
|
72
|
+
end
|
73
|
+
|
74
|
+
it "ignores options with help: false" do
|
75
|
+
@options.on "-x", "something", help: false
|
76
|
+
refute_match(/something/, @options.to_s)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/test/parser_test.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Slop::Parser do
|
4
|
+
before do
|
5
|
+
@options = Slop::Options.new
|
6
|
+
@verbose = @options.bool "-v", "--verbose"
|
7
|
+
@name = @options.string "-n", "--name"
|
8
|
+
@unused = @options.string "--unused"
|
9
|
+
@parser = Slop::Parser.new(@options)
|
10
|
+
@result = @parser.parse %w(foo -v --name lee argument)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "ignores everything after --" do
|
14
|
+
@parser.reset.parse %w(-v -- --name lee)
|
15
|
+
assert_equal [@verbose], @parser.used_options
|
16
|
+
end
|
17
|
+
|
18
|
+
it "parses flag=argument" do
|
19
|
+
@options.integer "-p", "--port"
|
20
|
+
@result.parser.reset.parse %w(--name=bob -p=123)
|
21
|
+
assert_equal "bob", @result[:name]
|
22
|
+
assert_equal 123, @result[:port]
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "parsing grouped short flags" do
|
26
|
+
before do
|
27
|
+
@options.bool "-q", "--quiet"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "parses boolean flags" do
|
31
|
+
@result.parser.reset.parse %w(-qv)
|
32
|
+
assert_equal true, @result.quiet?
|
33
|
+
assert_equal true, @result.verbose?
|
34
|
+
end
|
35
|
+
|
36
|
+
it "sends the argument to the last flag" do
|
37
|
+
@result.parser.reset.parse %w(-qvn foo)
|
38
|
+
assert_equal "foo", @result[:name]
|
39
|
+
end
|
40
|
+
|
41
|
+
it "doesn't screw up single hyphen long options" do
|
42
|
+
@options.string "-host"
|
43
|
+
@result.parser.reset.parse %w(-host localhost)
|
44
|
+
assert_equal "localhost", @result[:host]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#used_options" do
|
49
|
+
it "returns all options that were parsed" do
|
50
|
+
assert_equal [@verbose, @name], @parser.used_options
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#unused_options" do
|
55
|
+
it "returns all options that were not parsed" do
|
56
|
+
assert_equal [@unused], @parser.unused_options
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#arguments" do
|
61
|
+
it "returns all unparsed arguments" do
|
62
|
+
assert_equal %w(foo argument), @parser.arguments
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/test/result_test.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Slop
|
4
|
+
class ReverseEverythingOption < BoolOption
|
5
|
+
def finish(result)
|
6
|
+
result.used_options.grep(Slop::StringOption).each do |opt|
|
7
|
+
opt.value = opt.value.reverse
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe Slop::Result do
|
14
|
+
before do
|
15
|
+
@options = Slop::Options.new
|
16
|
+
@verbose = @options.bool "-v", "--verbose"
|
17
|
+
@name = @options.string "--name"
|
18
|
+
@unused = @options.string "--unused"
|
19
|
+
@result = @options.parse %w(foo -v --name lee argument)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "increments option count" do
|
23
|
+
# test this here so it's more "full stack"
|
24
|
+
assert_equal 1, @verbose.count
|
25
|
+
@result.parser.reset.parse %w(-v --verbose)
|
26
|
+
assert_equal 2, @verbose.count
|
27
|
+
end
|
28
|
+
|
29
|
+
it "handles default values" do
|
30
|
+
@options.string("--foo", default: "bar")
|
31
|
+
@result.parser.reset.parse %w()
|
32
|
+
assert_equal "bar", @result[:foo]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "handles custom finishing" do
|
36
|
+
@options.string "--foo"
|
37
|
+
@options.reverse_everything "-r"
|
38
|
+
@result.parser.reset.parse %w(-r --name lee --foo bar)
|
39
|
+
assert_equal %w(eel rab), @result.to_hash.values_at(:name, :foo)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "yields arguments to option blocks" do
|
43
|
+
output = nil
|
44
|
+
@options.string("--foo") { |v| output = v }
|
45
|
+
@result.parser.reset.parse %w(--foo bar)
|
46
|
+
assert_equal output, "bar"
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#[]" do
|
50
|
+
it "returns an options value" do
|
51
|
+
assert_equal "lee", @result["name"]
|
52
|
+
assert_equal "lee", @result[:name]
|
53
|
+
assert_equal "lee", @result["--name"]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#method_missing" do
|
58
|
+
it "checks if options have been used" do
|
59
|
+
assert_equal true, @result.verbose?
|
60
|
+
assert_equal false, @result.unused?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#option" do
|
65
|
+
it "returns an option by flag" do
|
66
|
+
assert_equal @verbose, @result.option("--verbose")
|
67
|
+
assert_equal @verbose, @result.option("-v")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "ignores prefixed hyphens" do
|
71
|
+
assert_equal @verbose, @result.option("verbose")
|
72
|
+
assert_equal @verbose, @result.option("-v")
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns nil if nothing is found" do
|
76
|
+
assert_equal nil, @result.option("foo")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#to_hash" do
|
81
|
+
it "returns option keys and values" do
|
82
|
+
assert_equal({ verbose: true, name: "lee", unused: nil }, @result.to_hash)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/test/test_helper.rb
ADDED
data/test/types_test.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Slop::BoolOption do
|
4
|
+
before do
|
5
|
+
@options = Slop::Options.new
|
6
|
+
@age = @options.bool "--verbose"
|
7
|
+
@age = @options.bool "--quiet"
|
8
|
+
@result = @options.parse %w(--verbose)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns true if used" do
|
12
|
+
assert_equal true, @result[:verbose]
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns false if not used" do
|
16
|
+
assert_equal false, @result[:quiet]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Slop::IntegerOption do
|
21
|
+
before do
|
22
|
+
@options = Slop::Options.new
|
23
|
+
@age = @options.integer "--age"
|
24
|
+
@result = @options.parse %w(--age 20)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the value as an integer" do
|
28
|
+
assert_equal 20, @result[:age]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns nil for non-numbers by default" do
|
32
|
+
@result.parser.reset.parse %w(--age hello)
|
33
|
+
assert_equal nil, @result[:age]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe Slop::ArrayOption do
|
38
|
+
before do
|
39
|
+
@options = Slop::Options.new
|
40
|
+
@files = @options.array "--files"
|
41
|
+
@delim = @options.array "-d", delimiter: ":"
|
42
|
+
@result = @options.parse %w(--files foo.txt,bar.rb)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "defaults to []" do
|
46
|
+
assert_equal [], @result[:d]
|
47
|
+
end
|
48
|
+
|
49
|
+
it "parses comma separated args" do
|
50
|
+
assert_equal %w(foo.txt bar.rb), @result[:files]
|
51
|
+
end
|
52
|
+
|
53
|
+
it "collects multiple option values" do
|
54
|
+
@result.parser.reset.parse %w(--files foo.txt --files bar.rb)
|
55
|
+
assert_equal %w(foo.txt bar.rb), @result[:files]
|
56
|
+
end
|
57
|
+
|
58
|
+
it "can use a custom delimiter" do
|
59
|
+
@result.parser.reset.parse %w(-d foo.txt:bar.rb)
|
60
|
+
assert_equal %w(foo.txt bar.rb), @result[:d]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe Slop::NullOption do
|
65
|
+
before do
|
66
|
+
@options = Slop::Options.new
|
67
|
+
@version = @options.null('--version')
|
68
|
+
@result = @options.parse %w(--version)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'has a return value of true' do
|
72
|
+
assert_equal true, @result[:version]
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'is not included in to_hash' do
|
76
|
+
assert_equal({}, @result.to_hash)
|
77
|
+
end
|
78
|
+
end
|
metadata
CHANGED
@@ -1,64 +1,70 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Jarvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 5.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 5.0.0
|
41
|
-
description: A
|
41
|
+
description: A DSL for gathering options and parsing command line flags
|
42
42
|
email: ljjarvis@gmail.com
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
-
- .gitignore
|
48
|
-
- .travis.yml
|
49
|
-
- CHANGES.md
|
47
|
+
- ".gitignore"
|
48
|
+
- ".travis.yml"
|
50
49
|
- Gemfile
|
51
50
|
- LICENSE
|
52
51
|
- README.md
|
53
52
|
- Rakefile
|
54
53
|
- lib/slop.rb
|
55
|
-
- lib/slop/
|
54
|
+
- lib/slop/error.rb
|
56
55
|
- lib/slop/option.rb
|
56
|
+
- lib/slop/options.rb
|
57
|
+
- lib/slop/parser.rb
|
58
|
+
- lib/slop/result.rb
|
59
|
+
- lib/slop/types.rb
|
57
60
|
- slop.gemspec
|
58
|
-
- test/
|
59
|
-
- test/helper.rb
|
61
|
+
- test/error_test.rb
|
60
62
|
- test/option_test.rb
|
61
|
-
- test/
|
63
|
+
- test/options_test.rb
|
64
|
+
- test/parser_test.rb
|
65
|
+
- test/result_test.rb
|
66
|
+
- test/test_helper.rb
|
67
|
+
- test/types_test.rb
|
62
68
|
homepage: http://github.com/leejarvis/slop
|
63
69
|
licenses:
|
64
70
|
- MIT
|
@@ -69,22 +75,25 @@ require_paths:
|
|
69
75
|
- lib
|
70
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
77
|
requirements:
|
72
|
-
- -
|
78
|
+
- - ">="
|
73
79
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
80
|
+
version: 2.0.0
|
75
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
82
|
requirements:
|
77
|
-
- -
|
83
|
+
- - ">="
|
78
84
|
- !ruby/object:Gem::Version
|
79
85
|
version: '0'
|
80
86
|
requirements: []
|
81
87
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
88
|
+
rubygems_version: 2.2.2
|
83
89
|
signing_key:
|
84
90
|
specification_version: 4
|
85
91
|
summary: Simple Lightweight Option Parsing
|
86
92
|
test_files:
|
87
|
-
- test/
|
88
|
-
- test/helper.rb
|
93
|
+
- test/error_test.rb
|
89
94
|
- test/option_test.rb
|
90
|
-
- test/
|
95
|
+
- test/options_test.rb
|
96
|
+
- test/parser_test.rb
|
97
|
+
- test/result_test.rb
|
98
|
+
- test/test_helper.rb
|
99
|
+
- test/types_test.rb
|
data/CHANGES.md
DELETED
@@ -1,309 +0,0 @@
|
|
1
|
-
3.6.0 (2014-06-18)
|
2
|
-
------------------
|
3
|
-
|
4
|
-
* Add example of rest arguments usage in the readme file #139
|
5
|
-
* Default values on options are printed in the help message #134
|
6
|
-
|
7
|
-
3.5.0 (2014-03-12)
|
8
|
-
------------------
|
9
|
-
|
10
|
-
* Add support for `as: Regexp` #132
|
11
|
-
|
12
|
-
3.4.7 (2013-11-14)
|
13
|
-
------------------
|
14
|
-
|
15
|
-
* Ensure trash is cleared on every parse so you can parse multiple
|
16
|
-
times with the same instance (#130)
|
17
|
-
|
18
|
-
3.4.5 (2013-05-14)
|
19
|
-
------------------
|
20
|
-
|
21
|
-
* Allow specifying long options starting with numbers (#110, Peter Zotov)
|
22
|
-
* Ensure short-options still consume trailing arguments, ie `-abc foo`
|
23
|
-
should assign `foo` to the option `c` if it expects an argument (#114).
|
24
|
-
|
25
|
-
3.4.4 (2013-03-12)
|
26
|
-
------------------
|
27
|
-
|
28
|
-
* Disable the run callback when the help option is used and `-h`
|
29
|
-
or `--help` is passed. #106
|
30
|
-
* Ensure default `--help` option exits by default (#107, Autumn Perrault).
|
31
|
-
|
32
|
-
3.4.3 (2013-01-14)
|
33
|
-
------------------
|
34
|
-
|
35
|
-
* Ensure `parse!` removes commands and their options.
|
36
|
-
|
37
|
-
3.4.2 (2013-01-14)
|
38
|
-
------------------
|
39
|
-
|
40
|
-
* Expose the Hash commands as public API.
|
41
|
-
* Deprecated `Slop.optspec`.
|
42
|
-
* Ensure help output prints to stdout, not stderr.
|
43
|
-
|
44
|
-
3.4.1 (2013-01-13)
|
45
|
-
------------------
|
46
|
-
|
47
|
-
* Ensure options replace any existing duplicates
|
48
|
-
* Command config options now inherit config options from top level Slop.
|
49
|
-
* Command help output now adds command in usage string.
|
50
|
-
|
51
|
-
3.4.0 (2013-01-12)
|
52
|
-
------------------
|
53
|
-
|
54
|
-
* Implement new command system (#95)
|
55
|
-
* Deprecate Slop::Commands
|
56
|
-
* Ensure 'no-foo' options are not inverted when parsing '--no-foo' (#86)
|
57
|
-
* Code refactoring and simplification (Kenichi Kamiya, #84, #85)
|
58
|
-
|
59
|
-
3.3.3 (2012-08-29)
|
60
|
-
------------------
|
61
|
-
|
62
|
-
* Ensure autocreate arguments are not created as options (#77)
|
63
|
-
* Ensure options are not swallowed when using short options with argument
|
64
|
-
included (#74)
|
65
|
-
|
66
|
-
3.3.2 (2012-06-26)
|
67
|
-
------------------
|
68
|
-
|
69
|
-
* Ensure multiple options are not executed unless they exist (#70)
|
70
|
-
|
71
|
-
3.3.1 (2012-05-31)
|
72
|
-
------------------
|
73
|
-
|
74
|
-
* Stop multiple switches from trashing arguments (Conrad Irwin, #66)
|
75
|
-
|
76
|
-
3.3.0 (2012-05-30)
|
77
|
-
------------------
|
78
|
-
|
79
|
-
* Fix `:as => :count` when using multiple switches.
|
80
|
-
* Ensure range typecast allows negative range values.
|
81
|
-
* Ignore nil objects send to #parse instead of choking.
|
82
|
-
|
83
|
-
3.2.0 (2012-05-15)
|
84
|
-
------------------
|
85
|
-
|
86
|
-
* Ensure boolean options appear correctly in `to_hash` output. (#59)
|
87
|
-
|
88
|
-
3.1.1 (2012-04-24)
|
89
|
-
------------------
|
90
|
-
|
91
|
-
* Ensure separators before any options are still being processed (#62)
|
92
|
-
|
93
|
-
3.1.0 (2012-04-23)
|
94
|
-
------------------
|
95
|
-
|
96
|
-
* Allow options to be fetched via underscores instead of dashes
|
97
|
-
(as a fallback) (Eric Anderson, #51)
|
98
|
-
* Added `Slop#strict?` method.
|
99
|
-
* Added strict checks for Integer/Float type casting. (Amon Sha)
|
100
|
-
* Ensure separators are not replacing existing separators (#61)
|
101
|
-
|
102
|
-
3.0.4 (2012-01-31)
|
103
|
-
------------------
|
104
|
-
|
105
|
-
* Ensure `option=argument` syntax does not consume following arguments (#55).
|
106
|
-
|
107
|
-
3.0.3 (2012-01-30)
|
108
|
-
------------------
|
109
|
-
|
110
|
-
* Ensure options passed after option terminator do not raise an exception
|
111
|
-
(#54, Amon Sha)
|
112
|
-
|
113
|
-
3.0.2 (2012-01-27)
|
114
|
-
------------------
|
115
|
-
|
116
|
-
* Ensure `--option=value` is being evaluated before multiple switches (#52)
|
117
|
-
|
118
|
-
3.0.1 (2012-01-27)
|
119
|
-
------------------
|
120
|
-
|
121
|
-
* Ensure tests run green on 1.8.7
|
122
|
-
* Ensure `:argument => :optional` works with `:option=` format.
|
123
|
-
* Ruby 1.8.7 compat fix (dont chain Enumerable methods!) (Eric Anderson)
|
124
|
-
|
125
|
-
3.0.0 (2012-01-24)
|
126
|
-
------------------
|
127
|
-
|
128
|
-
* value_to_range returns an x..x range if the value looks like an integer.
|
129
|
-
* Lots of code refactoring
|
130
|
-
* Use TomDoc documentation
|
131
|
-
* Added `Slop::Commands` and removed existing command system
|
132
|
-
* Configuration options altered:
|
133
|
-
* `:optional` has been renamed to `:optional_argument`
|
134
|
-
* Added `:required` for mandatory options
|
135
|
-
* `:argument` now accepts an `:optional` symbol as well as boolean value
|
136
|
-
* Removed Slop instance methods:
|
137
|
-
* description=, description
|
138
|
-
* summary=, summary
|
139
|
-
* command
|
140
|
-
* on_empty
|
141
|
-
* on_noopts
|
142
|
-
* execute
|
143
|
-
* to_struct
|
144
|
-
* Added Slop instance methods:
|
145
|
-
* separator
|
146
|
-
* fetch_option
|
147
|
-
* add_callback
|
148
|
-
|
149
|
-
2.4.3 (2012-01-16)
|
150
|
-
------------------
|
151
|
-
|
152
|
-
* Allow the `:as` option to accept an object responding to :call for
|
153
|
-
custom type conversions (#45)
|
154
|
-
* Ensure negative integers are not parsed as possible options (#46)
|
155
|
-
|
156
|
-
2.4.2 (2011-12-18)
|
157
|
-
------------------
|
158
|
-
|
159
|
-
* Fix checking of required options (Dominik Honnef)
|
160
|
-
|
161
|
-
2.4.1 (2011-12-08)
|
162
|
-
------------------
|
163
|
-
|
164
|
-
* Ensure optional arguments are returned correctly
|
165
|
-
|
166
|
-
2.4.0 (2011-11-26)
|
167
|
-
------------------
|
168
|
-
|
169
|
-
* Avoid `define_method` for checking an options presence (and caching it) #37
|
170
|
-
* Ensure the short option allows an appended `=` for accepting arguments
|
171
|
-
* Implement `respond_to?`
|
172
|
-
|
173
|
-
2.3.1 (2011-11-11)
|
174
|
-
------------------
|
175
|
-
|
176
|
-
* Return `nil` for any options using casting which don't expect arguments (#33)
|
177
|
-
* Fix parenthesis warning on 1.8.7 (@shevegen)
|
178
|
-
* Ensure long argument is a string before attempting to use `#[]` method on it
|
179
|
-
|
180
|
-
2.3.0 (2011-11-04)
|
181
|
-
------------------
|
182
|
-
|
183
|
-
* Allow flags to have suffixed `=` char for options which accept an argument
|
184
|
-
|
185
|
-
2.2.0 (2011-11-02)
|
186
|
-
------------------
|
187
|
-
|
188
|
-
* Support `bup.options` style optspec parsing
|
189
|
-
* http://apenwarr.ca/log/?m=201111
|
190
|
-
|
191
|
-
* Allow `:as` to accept a `count` value (Conrad Irwin):
|
192
|
-
|
193
|
-
`on :v, :verbose, :as => :count # -vv; opts[:verbose] #=> 2`
|
194
|
-
|
195
|
-
2.1.0 (2011-08-03)
|
196
|
-
------------------
|
197
|
-
|
198
|
-
* Added `Slop#missing` for returning a list of missing options parsed
|
199
|
-
* Allow `Slop#present?` to accept multiple arguments
|
200
|
-
* Added `:all_accept_arguments` to Slop configuration options, this saves
|
201
|
-
having to specify that every option takes an argument
|
202
|
-
* Added `Slop#to_struct` for building new classes from options
|
203
|
-
|
204
|
-
2.0.0 (2011-07-07)
|
205
|
-
------------------
|
206
|
-
|
207
|
-
* Deprecations:
|
208
|
-
* Removed `Slop::Options#to_hash` continue using `Slop#to_hash` directly.
|
209
|
-
This method also now returns symbols by default instead of strings. If
|
210
|
-
you want strings use `opts.to_hash(false)`
|
211
|
-
* `:multiple_switches` is now enabled by default, to parse `fbar` as the
|
212
|
-
option `f` with value `bar` you must disable `:multiple_switches`
|
213
|
-
* Removed `Slop::Options#to_help` and merged its contents into `Slop#help`
|
214
|
-
* Removed `lib/slop/options.rb` and merged `Slop::Options` into slop.rb
|
215
|
-
* Removed `lib/slop/option.rb` and merged `Slop::Option` into slop.rb
|
216
|
-
* These changes make Slop much easier to vendor in libraries
|
217
|
-
* `Slop::Option` now inherits from `Struct.new`
|
218
|
-
* Added Slop::Error subclassing from StandardError which all exception
|
219
|
-
classes should inherit from
|
220
|
-
* Added Slop::MissingOptionError and `:required` option to Slop::Option.
|
221
|
-
This exception is raised when a mandatory option is not used
|
222
|
-
|
223
|
-
1.9.1 (2011-06-16)
|
224
|
-
------------------
|
225
|
-
|
226
|
-
* Ensure optional items with no arguments still return true when searching
|
227
|
-
for presence
|
228
|
-
|
229
|
-
1.9.0 (2011-06-15)
|
230
|
-
------------------
|
231
|
-
|
232
|
-
* Add command completion and support for an error message when ambiguous
|
233
|
-
commands are used
|
234
|
-
* Add command aliases
|
235
|
-
* Fix: Ensure parsed elements are removed from original arguments when using
|
236
|
-
`:multiple_switches`
|
237
|
-
* Ensure anything after `--` is parsed as an argument and not option even
|
238
|
-
if prefixed with `/--?/`
|
239
|
-
* Performance improvements when making many calls to `Slop#option?` for
|
240
|
-
checking an options presence (Rob Gleeson)
|
241
|
-
* Ensure `execute` passes command arguments to the block
|
242
|
-
* Support for summary and description (Denis Defreyne)
|
243
|
-
|
244
|
-
1.8.0 (2011-06-12)
|
245
|
-
------------------
|
246
|
-
|
247
|
-
* Added `execute` method to Slop for commands. This block will be invoked
|
248
|
-
when a specific command is used. The Slop object will be yielded to the
|
249
|
-
block
|
250
|
-
* Allow passing a class name to `on` to be used as an `:as` option. ie:
|
251
|
-
`on :people, 'Some people', Array`
|
252
|
-
* Get smart with parsing options optparse style: `on '--name NAME'` and
|
253
|
-
`on 'password [OPTIONAL]'`
|
254
|
-
* Feature: `:arguments` setting to enable argument passing for all options
|
255
|
-
|
256
|
-
1.7.0 (2011-06-06)
|
257
|
-
------------------
|
258
|
-
|
259
|
-
* Feature: Autocreate (auto create options at parse time, making assumptions)
|
260
|
-
* Feature: When parsing options as arrays, push multiple arguments into a
|
261
|
-
single array
|
262
|
-
|
263
|
-
1.6.1 (2011-06-01)
|
264
|
-
------------------
|
265
|
-
|
266
|
-
* Fix tests and using a temporary Array for ARGV, fixes RubyGems Test issues
|
267
|
-
* General cleanup of code
|
268
|
-
|
269
|
-
1.6.0 (2011-05-18)
|
270
|
-
------------------
|
271
|
-
|
272
|
-
* Add `:ignore_case` to Slop options for case insensitive option matching
|
273
|
-
* Add `:on_noopts` for triggering an event when the arguments contain no
|
274
|
-
options
|
275
|
-
* Add `:unless` to Slop::Option for omitting execution of the Options block
|
276
|
-
when this object exists in the Array of items passed to Slop.new
|
277
|
-
* Bugfix: Do not parse negative integers as options. A valid option must
|
278
|
-
start with an alphabet character
|
279
|
-
* Bugfix: Allow a Range to accept a negative Integer at either end
|
280
|
-
|
281
|
-
1.5.5 (2011-05-03)
|
282
|
-
------------------
|
283
|
-
|
284
|
-
* Bugfix: only attempt to extract options prefixed with `-`
|
285
|
-
|
286
|
-
1.5.4 (2011-05-01)
|
287
|
-
------------------
|
288
|
-
|
289
|
-
* Bugfix: `parse!` should not remove items with the same value as items used
|
290
|
-
in option arguments. Fixes #22 (Utkarsh Kukreti)
|
291
|
-
|
292
|
-
1.5.3 (2011-04-22)
|
293
|
-
------------------
|
294
|
-
|
295
|
-
* Bugfix: Use integers when fetching array indexes, not strings
|
296
|
-
|
297
|
-
1.5.2 (2011-04-17)
|
298
|
-
------------------
|
299
|
-
|
300
|
-
* Bugfix: Ensure `ARGV` is empty when using the `on_empty` event
|
301
|
-
|
302
|
-
1.5.0 (2011-04-15)
|
303
|
-
------------------
|
304
|
-
|
305
|
-
* Add `Slop#get` as alias to `Slop#[]`
|
306
|
-
* Add `Slop#present?` as alias for `Slop#<option>?`
|
307
|
-
* Add `Option#count` for monitoring how many times an option is called
|
308
|
-
* Add `:io` for using a custom IO object when using the `:help` option
|
309
|
-
* Numerous performance tweaks
|