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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be6ead8f4e3fb70c94b061d779c3f552842d78acb16e3828e37b64d02804772b
4
- data.tar.gz: ec3ad13d30478c9048ea2ff74d07da4cd7c8e1d2efe99e3a569bd4fba09274f4
3
+ metadata.gz: 26579ef8c44c72bdb1176ab1d1916704a7c98526e65280c2380ea2eb266865eb
4
+ data.tar.gz: 9920dad59ac41bec67cbafcd5a6d4267a4d83055b095066f5f7d9020e7333a67
5
5
  SHA512:
6
- metadata.gz: 93555b428ac603ad16d90fde03a0ff26ff2d8ce7097f8b9d32a8d57d1685b7042c1e8cee4842aeba3e2396ba990eb34b47e7d5df0ef3f90135d3892bb53e97f7
7
- data.tar.gz: f306a8549e5b70abac451dc0d75add3a4266c2d66d3aa79c2f05b8efde26379505a91cfc5bbc99cfbcd72931942f8f536e91568e18df7f2e970b03dda537a028
6
+ metadata.gz: 3cb162c995baa0e74b483430173019b155710de995d684c8af21bdb583d2f14a129b55b09b871c87d33a94148be807f6841185428648acf1db562286fe8fbe3d
7
+ data.tar.gz: 83c8d247e109d3c8cd400713d1080f8e1bcc598028043ca21c31db11e2736c4087b918d97d0dd7cd5b42974fc65ff1be56f8b96cf9a5b21737f710aba227a568
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.1.0 (2025-03-03)
2
+
3
+ * Support after_options method for a block called after options processing (jeremyevans)
4
+
1
5
  === 1.0.0 (2025-02-27)
2
6
 
3
7
  * Initial Public Release
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+
@@ -56,8 +56,13 @@ module Rodish
56
56
  # of normal subcommands.
57
57
  attr_accessor :post_option_key
58
58
 
59
- # A before hook to execute before executing the current
60
- # command or dispatching to subcommands.
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.0.0
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-02-27 00:00:00.000000000 Z
10
+ date: 2025-03-04 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: optparse