slop 4.9.1 → 4.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +35 -0
- data/CHANGELOG.md +12 -0
- data/README.md +5 -3
- data/lib/slop/parser.rb +1 -1
- data/lib/slop/types.rb +3 -1
- data/lib/slop.rb +1 -1
- data/test/parser_test.rb +18 -9
- data/test/types_test.rb +7 -1
- metadata +4 -4
- data/.travis.yml +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e59ff0d4bd9fa111d71e057b9e3ae9aa1aebef93937fcf7f1e1d57fb789c010
|
4
|
+
data.tar.gz: 1628f1e9cfa67ca737b494b65d135d4b28ee7f16fb9b9bfeb746d54a2d83b1b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f1aea5c8faeb6d7d6a995f3853b97f9c8c80ed57fcaf692c3113fb5b7b4886323677e4adf5e6595975748beaca585d700949f3739dc82f81913563bc7b9a318
|
7
|
+
data.tar.gz: c75a58a1341a177152ae5d8827d3f980d6a395854123c2ab5612837835c723123c38d84239e299a50012f5b3ce017566244efa41bcfb97bfbc53a077867e9bea
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
paths:
|
7
|
+
- "lib/**"
|
8
|
+
- "test/**"
|
9
|
+
- ".github/**"
|
10
|
+
- "Rakefile"
|
11
|
+
pull_request:
|
12
|
+
branches: ["**"]
|
13
|
+
paths:
|
14
|
+
- "lib/**"
|
15
|
+
- "test/**"
|
16
|
+
- ".github/**"
|
17
|
+
- "Rakefile"
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
tests:
|
21
|
+
runs-on: ubuntu-latest
|
22
|
+
strategy:
|
23
|
+
fail-fast: false
|
24
|
+
matrix:
|
25
|
+
ruby: [ "2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "3.0", "3.1", head, jruby, truffleruby ]
|
26
|
+
name: Ruby ${{ matrix.ruby }}
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v2
|
29
|
+
- name: Set up Ruby
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
33
|
+
bundler: none
|
34
|
+
- name: Run tests
|
35
|
+
run: rake test
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
v4.9.3 (2022-09-30)
|
5
|
+
-------------------
|
6
|
+
|
7
|
+
Bug fixes:
|
8
|
+
* Fix explicitly false boolean options and allow for additional false arguments [#276](https://github.com/leejarvis/slop/pull/276) (Eugene Otto)
|
9
|
+
|
10
|
+
v4.9.2 (2022-03-26)
|
11
|
+
-------------------
|
12
|
+
|
13
|
+
Bug fixes:
|
14
|
+
* Handle flag arguments that contain equals character [#275](https://github.com/leejarvis/slop/pull/275) (ConnorWGarvey)
|
15
|
+
|
4
16
|
v4.9.1 (2021-05-28)
|
5
17
|
-------------------
|
6
18
|
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ Slop
|
|
3
3
|
|
4
4
|
Slop is a simple option parser with an easy to remember syntax and friendly API.
|
5
5
|
|
6
|
-
[![Build Status](https://
|
6
|
+
[![Build Status](https://github.com/leejarvis/slop/actions/workflows/ci.yml/badge.svg)](https://github.com/leejarvis/slop/actions/workflows/ci.yml)
|
7
7
|
|
8
8
|
Installation
|
9
9
|
------------
|
@@ -22,17 +22,19 @@ opts = Slop.parse do |o|
|
|
22
22
|
o.bool '-v', '--verbose', 'enable verbose mode'
|
23
23
|
o.bool '-q', '--quiet', 'suppress output (quiet mode)'
|
24
24
|
o.bool '-c', '--check-ssl-certificate', 'check SSL certificate for host'
|
25
|
+
o.bool '-k', '--use-keychain', 'store passphrase in OS keychain'
|
25
26
|
o.on '--version', 'print the version' do
|
26
27
|
puts Slop::VERSION
|
27
28
|
exit
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
ARGV #=> -v --login alice --host 192.168.0.1 -m post --check-ssl-certificate
|
32
|
+
ARGV #=> -v --login alice --host 192.168.0.1 -m post --check-ssl-certificate --use-keychain false
|
32
33
|
|
33
34
|
opts[:host] #=> 192.168.0.1
|
34
35
|
opts[:login] #=> alice
|
35
36
|
opts[:method] #=> :post
|
37
|
+
opts[:use_keychain] #=> false
|
36
38
|
opts.verbose? #=> true
|
37
39
|
opts.quiet? #=> false
|
38
40
|
opts.check_ssl_certificate? #=> true
|
@@ -53,7 +55,7 @@ Built in Option types are as follows:
|
|
53
55
|
|
54
56
|
```ruby
|
55
57
|
o.string #=> Slop::StringOption, expects an argument
|
56
|
-
o.bool #=> Slop::BoolOption,
|
58
|
+
o.bool #=> Slop::BoolOption, argument optional, aliased to BooleanOption
|
57
59
|
o.integer #=> Slop::IntegerOption, expects an argument, aliased to IntOption
|
58
60
|
o.float #=> Slop::FloatOption, expects an argument
|
59
61
|
o.array #=> Slop::ArrayOption, expects an argument
|
data/lib/slop/parser.rb
CHANGED
data/lib/slop/types.rb
CHANGED
@@ -21,6 +21,8 @@ module Slop
|
|
21
21
|
class BoolOption < Option
|
22
22
|
attr_accessor :explicit_value
|
23
23
|
|
24
|
+
FALSE_VALUES = [false, 'false', 'no', 'off', '0'].freeze
|
25
|
+
|
24
26
|
def call(value)
|
25
27
|
self.explicit_value = value
|
26
28
|
!force_false?
|
@@ -35,7 +37,7 @@ module Slop
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def force_false?
|
38
|
-
explicit_value
|
40
|
+
FALSE_VALUES.include?(explicit_value)
|
39
41
|
end
|
40
42
|
|
41
43
|
def default_value
|
data/lib/slop.rb
CHANGED
data/test/parser_test.rb
CHANGED
@@ -17,16 +17,25 @@ describe Slop::Parser do
|
|
17
17
|
assert_equal ["-v", "--name", "lee"], @parser.arguments
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
describe "for flag=argument" do
|
21
|
+
it "parses names and values" do
|
22
|
+
@options.integer "-p", "--port"
|
23
|
+
@result.parser.parse %w(--name=bob -p=123)
|
24
|
+
assert_equal "bob", @result[:name]
|
25
|
+
assert_equal 123, @result[:port]
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
it "treats an = separated by a space as a value" do
|
29
|
+
@options.string "--foo"
|
30
|
+
@result.parser.parse %w(--foo = =)
|
31
|
+
assert_equal "=", @result[:foo]
|
32
|
+
assert_equal %w(=), @result.args
|
33
|
+
end
|
34
|
+
|
35
|
+
it "includes = in strings" do
|
36
|
+
@result.parser.parse(%w(--name=b=b))
|
37
|
+
assert_equal "b=b", @result[:name]
|
38
|
+
end
|
30
39
|
end
|
31
40
|
|
32
41
|
it "parses flag=''" do
|
data/test/types_test.rb
CHANGED
@@ -34,9 +34,11 @@ describe Slop::BoolOption do
|
|
34
34
|
@verbose = @options.bool "--verbose"
|
35
35
|
@quiet = @options.bool "--quiet"
|
36
36
|
@inversed = @options.bool "--inversed", default: true
|
37
|
+
@explicit = @options.bool "--explicit"
|
37
38
|
@bloc = @options.bool("--bloc"){|val| (@bloc_val ||= []) << val}
|
38
39
|
@result = @options.parse %w(--verbose --no-inversed
|
39
|
-
--bloc --no-bloc
|
40
|
+
--bloc --no-bloc
|
41
|
+
--explicit=false)
|
40
42
|
end
|
41
43
|
|
42
44
|
it "returns true if used" do
|
@@ -54,6 +56,10 @@ describe Slop::BoolOption do
|
|
54
56
|
it "will invert the value passed to &block via --no- prefix" do
|
55
57
|
assert_equal [true, false], @bloc_val
|
56
58
|
end
|
59
|
+
|
60
|
+
it "returns false when explicitly false" do
|
61
|
+
assert_equal false, @result[:explicit]
|
62
|
+
end
|
57
63
|
end
|
58
64
|
|
59
65
|
describe Slop::IntegerOption do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.9.
|
4
|
+
version: 4.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Jarvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -44,8 +44,8 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
+
- ".github/workflows/ci.yml"
|
47
48
|
- ".gitignore"
|
48
|
-
- ".travis.yml"
|
49
49
|
- CHANGELOG.md
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
89
|
+
rubygems_version: 3.3.7
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Simple Lightweight Option Parsing
|
data/.travis.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
cache: bundler
|
2
|
-
before_install:
|
3
|
-
- |
|
4
|
-
export RVM_CURRENT=`rvm current|cut -c6-8`
|
5
|
-
if [ "${RVM_CURRENT}" = "2.0" ] || \
|
6
|
-
[ "${RVM_CURRENT}" = "2.1" ] || \
|
7
|
-
[ "${RVM_CURRENT}" = "2.2" ]; then
|
8
|
-
gem install bundler -v '< 2'
|
9
|
-
fi
|
10
|
-
|
11
|
-
rvm:
|
12
|
-
- 2.0.0
|
13
|
-
- 2.1
|
14
|
-
- 2.2
|
15
|
-
- 2.3.4
|
16
|
-
- 2.4.10
|
17
|
-
- 2.5.9
|
18
|
-
- 2.6.7
|
19
|
-
- 2.7.3
|
20
|
-
- 3.0.1
|
21
|
-
- jruby-9.2.17.0
|
22
|
-
- jruby-head
|
23
|
-
- ruby-head
|
24
|
-
- truffleruby-head
|
25
|
-
jdk:
|
26
|
-
- openjdk8
|
27
|
-
notifications:
|
28
|
-
email:
|
29
|
-
on_success: change
|
30
|
-
on_failure: always
|