cl 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/Gemfile.lock +1 -1
- data/README.md +27 -0
- data/lib/cl/cmd.rb +5 -5
- data/lib/cl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ad6f463c61d2ec0f5db88d560d738fcc671a095
|
4
|
+
data.tar.gz: 63b2ea1908c0112f1baf7d3d1e28a8481e54659f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d043d77bfeac6e2a761027995c22ae1e3dadbc947e0eac008a5efbc4e7805811b720914df9ab1d904611b7dc998c298ed3bc69951ed0355a68945e1c0ef0497a
|
7
|
+
data.tar.gz: bb6bc3786118b64a4f4279af512f788d6f919fdfaafd708c38521fc970e405dba5b58b5a2f9a444c364a2d35e7ae5718a4e66e53e5c2e86fab371d44fcacf6d7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,36 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.2.4 (2020-01-18)
|
4
|
+
|
5
|
+
* Make auto-registration optional, but on by default
|
6
|
+
|
7
|
+
## 1.2.3 (2020-01-17)
|
8
|
+
|
9
|
+
* Bring back auto regisration (broke dpl)
|
10
|
+
|
11
|
+
## 1.2.2 (2020-01-17)
|
12
|
+
|
13
|
+
* Do not auto-register commands by default
|
14
|
+
|
15
|
+
## 1.2.1 (2020-01-14)
|
16
|
+
|
17
|
+
* Fix calling const.include on older Ruby versions
|
18
|
+
|
19
|
+
## 1.2.0 (2020-01-14)
|
20
|
+
|
21
|
+
* Enforce declaring arguments
|
22
|
+
* Allow optional strings on long opts
|
23
|
+
* Define arg accessor on an included module so it can be overwritten
|
24
|
+
* Inherit args from parent commands
|
25
|
+
* Do not raise on empty splats
|
26
|
+
* Allow args to have defaults
|
27
|
+
* Allow args to be enums
|
28
|
+
* Define predicate methods for args
|
29
|
+
* Make flag values an optional feature
|
30
|
+
* List multiple usage lines if a command has multiple registry keys
|
31
|
+
* Sort options by class hierarchie
|
32
|
+
* Do not try to cast nil values to integers
|
33
|
+
|
3
34
|
## 1.1.3 (2019-09-02)
|
4
35
|
|
5
36
|
* Rescue OptionParser::InvalidOption, suggest known options
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -153,6 +153,33 @@ module One
|
|
153
153
|
end
|
154
154
|
```
|
155
155
|
|
156
|
+
By default commands auto register themselves with the underscored name of the
|
157
|
+
last part of their class name (as seen in the example above). It is possible to
|
158
|
+
turn this off using:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
Cl::Cmd.auto_register = false
|
162
|
+
```
|
163
|
+
|
164
|
+
Command auto-registration can cause name clashes when namespaced commands have
|
165
|
+
the same demodulized class name. For example:
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
class Git < Cl::Cmd
|
169
|
+
# auto-registers as :git
|
170
|
+
end
|
171
|
+
|
172
|
+
module Heroku
|
173
|
+
class Git < Cl::Cmd
|
174
|
+
# also auto-registers as :git
|
175
|
+
end
|
176
|
+
end
|
177
|
+
```
|
178
|
+
|
179
|
+
It is recommended to turn auto-registration off when using such module
|
180
|
+
structures.
|
181
|
+
|
182
|
+
|
156
183
|
### Runners
|
157
184
|
|
158
185
|
Runners lookup the command to execute from the registry, by checking the
|
data/lib/cl/cmd.rb
CHANGED
@@ -6,9 +6,6 @@ require 'cl/opts'
|
|
6
6
|
require 'cl/parser'
|
7
7
|
|
8
8
|
class Cl
|
9
|
-
singleton_class.send(:attr_accessor, :auto_register) # remove unless anyone needs this
|
10
|
-
singleton_class.instance_variable_set(:@auto_register, true)
|
11
|
-
|
12
9
|
# Base class for all command classes that can be run.
|
13
10
|
#
|
14
11
|
# Inherit your command classes from this class, use the {Cl::Cmd::Dsl} to
|
@@ -23,9 +20,10 @@ class Cl
|
|
23
20
|
class << self
|
24
21
|
include Merge, Suggest, Underscore
|
25
22
|
|
23
|
+
attr_accessor :auto_register
|
24
|
+
|
26
25
|
inherited = ->(const) do
|
27
|
-
|
28
|
-
if const.name
|
26
|
+
if const.name && Cmd.auto_register
|
29
27
|
key = underscore(const.name.split('::').last)
|
30
28
|
key = [registry_key, key].compact.join(':') unless abstract?
|
31
29
|
const.register(key)
|
@@ -50,6 +48,8 @@ class Cl
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
51
|
+
self.auto_register = true
|
52
|
+
|
53
53
|
abstract
|
54
54
|
|
55
55
|
opt '--help', 'Get help on this command'
|
data/lib/cl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: regstry
|