rodish 1.0.0 → 1.1.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/CHANGELOG +4 -0
- data/README.rdoc +8 -0
- data/lib/rodish/command.rb +8 -2
- data/lib/rodish/dsl.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26579ef8c44c72bdb1176ab1d1916704a7c98526e65280c2380ea2eb266865eb
|
4
|
+
data.tar.gz: 9920dad59ac41bec67cbafcd5a6d4267a4d83055b095066f5f7d9020e7333a67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb162c995baa0e74b483430173019b155710de995d684c8af21bdb583d2f14a129b55b09b871c87d33a94148be807f6841185428648acf1db562286fe8fbe3d
|
7
|
+
data.tar.gz: 83c8d247e109d3c8cd400713d1080f8e1bcc598028043ca21c31db11e2736c4087b918d97d0dd7cd5b42974fc65ff1be56f8b96cf9a5b21737f710aba227a568
|
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -142,6 +142,14 @@ The +is+ method also takes +args+ and +invalid_args_message+ keyword arguments.
|
|
142
142
|
The +before+ method takes a block, and this block is executed before command
|
143
143
|
or subcommand execution, in the same context that the +run+ block would be
|
144
144
|
executed in. It is passed the remaining argv array and the already parsed
|
145
|
+
options. This is not called if an invalid subcommand is requested and there
|
146
|
+
is no run block for the command.
|
147
|
+
|
148
|
+
== +after_options+
|
149
|
+
|
150
|
+
The +after_options+ method takes a block, and this block is executed
|
151
|
+
directly after options parsing, in the same context that the +run+ block would be
|
152
|
+
executed in. It is passed the remaining argv array and the already parsed
|
145
153
|
options.
|
146
154
|
|
147
155
|
== +skip_option_parsing+
|
data/lib/rodish/command.rb
CHANGED
@@ -56,8 +56,13 @@ module Rodish
|
|
56
56
|
# of normal subcommands.
|
57
57
|
attr_accessor :post_option_key
|
58
58
|
|
59
|
-
# A
|
60
|
-
|
59
|
+
# A hook to execute after parsing options for the command.
|
60
|
+
attr_accessor :after_options
|
61
|
+
|
62
|
+
# A hook to execute before executing the current
|
63
|
+
# command or dispatching to subcommands. This will not
|
64
|
+
# be called if an invalid subcommand is given and no
|
65
|
+
# run block is present.
|
61
66
|
attr_accessor :before
|
62
67
|
|
63
68
|
# The number of arguments the run block will accept.
|
@@ -118,6 +123,7 @@ module Rodish
|
|
118
123
|
# that subcommand. If not, it dispatches to the run block.
|
119
124
|
def process(context, options, argv)
|
120
125
|
process_options(argv, options, @option_key, @option_parser)
|
126
|
+
context.instance_exec(argv, options, &after_options) if after_options
|
121
127
|
|
122
128
|
arg = argv[0]
|
123
129
|
if argv && @subcommands[arg]
|
data/lib/rodish/dsl.rb
CHANGED
@@ -65,9 +65,17 @@ module Rodish
|
|
65
65
|
@command.post_option_parser = create_option_parser(banner, @command.post_subcommands, &block)
|
66
66
|
end
|
67
67
|
|
68
|
+
# Sets the after_options block. This block is executed in the same
|
69
|
+
# context as the run block would be executed, directly after
|
70
|
+
# option parsing.
|
71
|
+
def after_options(&block)
|
72
|
+
@command.after_options = block
|
73
|
+
end
|
74
|
+
|
68
75
|
# Sets the before block. This block is executed in the same
|
69
76
|
# context as the run block would be executed, before either
|
70
77
|
# subcommand execution or execution of the current command.
|
78
|
+
# It is not called on invalid or missing subcommands.
|
71
79
|
def before(&block)
|
72
80
|
@command.before = block
|
73
81
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: optparse
|