gli 2.20.1 → 2.21.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +5 -3
- data/CONTRIBUTING.md +1 -3
- data/Rakefile +1 -1
- data/lib/gli/app_support.rb +3 -1
- data/lib/gli/commands/scaffold.rb +3 -3
- data/lib/gli/dsl.rb +5 -0
- data/lib/gli/gli_option_parser.rb +19 -4
- data/lib/gli/version.rb +1 -1
- data/test/integration/gli_powered_app_test.rb +1 -1
- data/test/unit/gli_test.rb +30 -0
- metadata +7 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c5897528d1a6f46c909f258df73970b5d91b23442fabbbe3324266462e61153
|
4
|
+
data.tar.gz: fe51d0fdfed0f4ee886f13d0cc70d02b346dd5e2243323927b0641e724173a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7877fdd663edee99a4df3a6c18c4df51fda9058382736583b22fac289834642eec9088800323df8168cf2d726ac8dcc7411f8686a1b5c57e2aa226fa7fc99312
|
7
|
+
data.tar.gz: d8f84289b949bd8d92ed1716327e8c8446b9bef71a596d9c9d30f5a098957c1b53bd48b3b9d848d005e6543139222514bda226476b50054d644eb2e2846070b3
|
data/.circleci/config.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
version: 2.1
|
2
2
|
orbs:
|
3
3
|
# See https://circleci.com/developer/orbs/orb/circleci/ruby
|
4
|
-
ruby: circleci/ruby@
|
4
|
+
ruby: circleci/ruby@2.0.1
|
5
5
|
jobs: # keyword
|
6
6
|
test: # my name for the job
|
7
7
|
parameters: # keyword
|
@@ -16,7 +16,7 @@ jobs: # keyword
|
|
16
16
|
- run:
|
17
17
|
command: "bin/setup"
|
18
18
|
- run:
|
19
|
-
command: "bin/ci"
|
19
|
+
command: "bin/ci none"
|
20
20
|
workflows: # keyword
|
21
21
|
all-rubies: # my name for the workflow
|
22
22
|
jobs: # keyword
|
@@ -25,4 +25,6 @@ workflows: # keyword
|
|
25
25
|
parameters: # keyword
|
26
26
|
# All rubies being maintained per this page:
|
27
27
|
# https://www.ruby-lang.org/en/downloads/branches/
|
28
|
-
|
28
|
+
# These also need to have complete version numbers
|
29
|
+
# or rvm won't install
|
30
|
+
ruby-version: [ "3.0.4", "3.1.3", "3.2.2" ]
|
data/CONTRIBUTING.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Contributions are welcome as long as they are part of my vision for GLI (or can be treated as optional to the user). I am obsessive about backwards-compatibility, so you may need to default things to disable your features. Sorry, not ready to bump a major version any time soon.
|
2
2
|
|
3
3
|
1. Fork my Repository
|
4
|
-
2. Create a branch off of
|
4
|
+
2. Create a branch off of main
|
5
5
|
3. Make your changes:
|
6
6
|
* Please include tests and watch out for reek and roodi; i.e. keep your code clean
|
7
7
|
* If you make changes to the gli executable or the scaffolding, please update the cucumber features
|
@@ -19,5 +19,3 @@ Contributions are welcome as long as they are part of my vision for GLI (or can
|
|
19
19
|
* Use <code># :nodoc:</code> for methods that a _user_ of GLI should not call (but still please do document all methods)
|
20
20
|
4. Make sure your branch will merge with my gli-2 branch (or just rebase your branch from my gli-2 branch)
|
21
21
|
5. Create a pull request explaining your change
|
22
|
-
|
23
|
-
|
data/Rakefile
CHANGED
data/lib/gli/app_support.rb
CHANGED
@@ -15,6 +15,7 @@ module GLI
|
|
15
15
|
switches.clear
|
16
16
|
flags.clear
|
17
17
|
@commands = nil
|
18
|
+
@command_missing_block = nil
|
18
19
|
@commands_declaration_order = []
|
19
20
|
@flags_declaration_order = []
|
20
21
|
@switches_declaration_order = []
|
@@ -72,7 +73,8 @@ module GLI
|
|
72
73
|
:default_command => @default_command,
|
73
74
|
:autocomplete => autocomplete,
|
74
75
|
:subcommand_option_handling_strategy => subcommand_option_handling_strategy,
|
75
|
-
:argument_handling_strategy => argument_handling_strategy
|
76
|
+
:argument_handling_strategy => argument_handling_strategy,
|
77
|
+
:command_missing_block => @command_missing_block)
|
76
78
|
|
77
79
|
parsing_result = gli_option_parser.parse_options(args)
|
78
80
|
parsing_result.convert_to_openstruct! if @use_openstruct
|
@@ -70,9 +70,9 @@ spec = Gem::Specification.new do |s|
|
|
70
70
|
s.rdoc_options << '--title' << '#{project_name}' << '--main' << 'README.rdoc' << '-ri'
|
71
71
|
s.bindir = 'bin'
|
72
72
|
s.executables << '#{project_name}'
|
73
|
-
s.add_development_dependency('rake'
|
74
|
-
s.add_development_dependency('rdoc'
|
75
|
-
s.add_development_dependency('minitest'
|
73
|
+
s.add_development_dependency('rake')
|
74
|
+
s.add_development_dependency('rdoc')
|
75
|
+
s.add_development_dependency('minitest')
|
76
76
|
s.add_runtime_dependency('gli','~> #{GLI::VERSION}')
|
77
77
|
end
|
78
78
|
EOS
|
data/lib/gli/dsl.rb
CHANGED
@@ -201,9 +201,14 @@ module GLI
|
|
201
201
|
end
|
202
202
|
clear_nexts
|
203
203
|
@next_arguments = []
|
204
|
+
command
|
204
205
|
end
|
205
206
|
alias :c :command
|
206
207
|
|
208
|
+
def command_missing(&block)
|
209
|
+
@command_missing_block = block
|
210
|
+
end
|
211
|
+
|
207
212
|
def flags_declaration_order # :nodoc:
|
208
213
|
@flags_declaration_order ||= []
|
209
214
|
end
|
@@ -16,7 +16,7 @@ module GLI
|
|
16
16
|
command_finder = CommandFinder.new(commands,
|
17
17
|
:default_command => (options[:default_command] || :help),
|
18
18
|
:autocomplete => options[:autocomplete])
|
19
|
-
@global_option_parser = GlobalOptionParser.new(OptionParserFactory.new(flags,switches,accepts),command_finder,flags)
|
19
|
+
@global_option_parser = GlobalOptionParser.new(OptionParserFactory.new(flags,switches,accepts),command_finder,flags, :command_missing_block => options[:command_missing_block])
|
20
20
|
@accepts = accepts
|
21
21
|
if options[:argument_handling_strategy] == :strict && options[:subcommand_option_handling_strategy] != :normal
|
22
22
|
raise ArgumentError, "To use strict argument handling, you must enable normal subcommand_option_handling, e.g. subcommand_option_handling :normal"
|
@@ -36,10 +36,11 @@ module GLI
|
|
36
36
|
private
|
37
37
|
|
38
38
|
class GlobalOptionParser
|
39
|
-
def initialize(option_parser_factory,command_finder,flags)
|
39
|
+
def initialize(option_parser_factory,command_finder,flags,options={})
|
40
40
|
@option_parser_factory = option_parser_factory
|
41
41
|
@command_finder = command_finder
|
42
42
|
@flags = flags
|
43
|
+
@options = options
|
43
44
|
end
|
44
45
|
|
45
46
|
def parse!(parsing_result)
|
@@ -50,7 +51,21 @@ module GLI
|
|
50
51
|
else
|
51
52
|
parsing_result.arguments.shift
|
52
53
|
end
|
53
|
-
parsing_result.command =
|
54
|
+
parsing_result.command = begin
|
55
|
+
@command_finder.find_command(command_name)
|
56
|
+
rescue UnknownCommand => e
|
57
|
+
raise e unless @options[:command_missing_block]
|
58
|
+
command = @options[:command_missing_block].call(command_name.to_sym,parsing_result.global_options)
|
59
|
+
if command
|
60
|
+
unless command.is_a?(Command)
|
61
|
+
raise UnknownCommand.new("Expected the `command_missing` block to return a GLI::Command object, got a #{command.class.name} instead.")
|
62
|
+
end
|
63
|
+
else
|
64
|
+
raise e
|
65
|
+
end
|
66
|
+
command
|
67
|
+
end
|
68
|
+
|
54
69
|
unless command_name == 'help'
|
55
70
|
verify_required_options!(@flags, parsing_result.command, parsing_result.global_options)
|
56
71
|
end
|
@@ -143,7 +158,7 @@ module GLI
|
|
143
158
|
break
|
144
159
|
rescue UnknownCommand
|
145
160
|
arguments.unshift(next_command_name)
|
146
|
-
# Although command finder could
|
161
|
+
# Although command finder could certainly know if it should use
|
147
162
|
# the default command, it has no way to put the "unknown command"
|
148
163
|
# back into the argument stack. UGH.
|
149
164
|
unless command.get_default_command.nil?
|
data/lib/gli/version.rb
CHANGED
data/test/unit/gli_test.rb
CHANGED
@@ -783,6 +783,36 @@ class GLITest < MiniTest::Test
|
|
783
783
|
assert_equal %w(-f some_flag foo bar blah),argv
|
784
784
|
end
|
785
785
|
|
786
|
+
def test_missing_command
|
787
|
+
@called = false
|
788
|
+
@app.command_missing do |command_name, global_options|
|
789
|
+
@app.command command_name do |c|
|
790
|
+
c.action do
|
791
|
+
@called = true
|
792
|
+
end
|
793
|
+
end
|
794
|
+
end
|
795
|
+
|
796
|
+
assert_equal 0, @app.run(['foobar']),"Expected exit status to be 0"
|
797
|
+
assert @called,"Expected missing command to be called"
|
798
|
+
end
|
799
|
+
|
800
|
+
def test_missing_command_not_handled
|
801
|
+
@app.command_missing do |command_name, global_options|
|
802
|
+
# do nothing, i.e. don't handle the command
|
803
|
+
end
|
804
|
+
|
805
|
+
assert_equal 64,@app.run(['foobar']),"Expected exit status to be 64"
|
806
|
+
end
|
807
|
+
|
808
|
+
def test_missing_command_returns_non_command_object
|
809
|
+
@app.command_missing do |command_name, global_options|
|
810
|
+
true
|
811
|
+
end
|
812
|
+
|
813
|
+
assert_equal 64,@app.run(['foobar']),"Expected exit status to be 64"
|
814
|
+
end
|
815
|
+
|
786
816
|
private
|
787
817
|
|
788
818
|
def do_test_flag_create(object)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.21.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Copeland
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -205,7 +205,7 @@ homepage: http://davetron5000.github.io/gli
|
|
205
205
|
licenses:
|
206
206
|
- Apache-2.0
|
207
207
|
metadata: {}
|
208
|
-
post_install_message:
|
208
|
+
post_install_message:
|
209
209
|
rdoc_options:
|
210
210
|
- "--title"
|
211
211
|
- Git Like Interface
|
@@ -224,54 +224,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
- !ruby/object:Gem::Version
|
225
225
|
version: '0'
|
226
226
|
requirements: []
|
227
|
-
rubygems_version: 3.
|
228
|
-
signing_key:
|
227
|
+
rubygems_version: 3.4.17
|
228
|
+
signing_key:
|
229
229
|
specification_version: 4
|
230
230
|
summary: Build command-suite CLI apps that are awesome.
|
231
|
-
test_files:
|
232
|
-
- test/apps/README.md
|
233
|
-
- test/apps/todo/Gemfile
|
234
|
-
- test/apps/todo/README.rdoc
|
235
|
-
- test/apps/todo/Rakefile
|
236
|
-
- test/apps/todo/bin/todo
|
237
|
-
- test/apps/todo/lib/todo/commands/create.rb
|
238
|
-
- test/apps/todo/lib/todo/commands/list.rb
|
239
|
-
- test/apps/todo/lib/todo/commands/ls.rb
|
240
|
-
- test/apps/todo/lib/todo/commands/make.rb
|
241
|
-
- test/apps/todo/lib/todo/version.rb
|
242
|
-
- test/apps/todo/test/tc_nothing.rb
|
243
|
-
- test/apps/todo/todo.gemspec
|
244
|
-
- test/apps/todo/todo.rdoc
|
245
|
-
- test/apps/todo_legacy/Gemfile
|
246
|
-
- test/apps/todo_legacy/README.rdoc
|
247
|
-
- test/apps/todo_legacy/Rakefile
|
248
|
-
- test/apps/todo_legacy/bin/todo
|
249
|
-
- test/apps/todo_legacy/lib/todo/commands/create.rb
|
250
|
-
- test/apps/todo_legacy/lib/todo/commands/list.rb
|
251
|
-
- test/apps/todo_legacy/lib/todo/commands/ls.rb
|
252
|
-
- test/apps/todo_legacy/lib/todo/version.rb
|
253
|
-
- test/apps/todo_legacy/test/tc_nothing.rb
|
254
|
-
- test/apps/todo_legacy/todo.gemspec
|
255
|
-
- test/apps/todo_legacy/todo.rdoc
|
256
|
-
- test/apps/todo_plugins/commands/third.rb
|
257
|
-
- test/integration/gli_cli_test.rb
|
258
|
-
- test/integration/gli_powered_app_test.rb
|
259
|
-
- test/integration/scaffold_test.rb
|
260
|
-
- test/integration/test_helper.rb
|
261
|
-
- test/unit/command_finder_test.rb
|
262
|
-
- test/unit/command_test.rb
|
263
|
-
- test/unit/compound_command_test.rb
|
264
|
-
- test/unit/doc_test.rb
|
265
|
-
- test/unit/flag_test.rb
|
266
|
-
- test/unit/gli_test.rb
|
267
|
-
- test/unit/help_test.rb
|
268
|
-
- test/unit/init_simplecov.rb
|
269
|
-
- test/unit/options_test.rb
|
270
|
-
- test/unit/subcommand_parsing_test.rb
|
271
|
-
- test/unit/subcommands_test.rb
|
272
|
-
- test/unit/support/fake_std_out.rb
|
273
|
-
- test/unit/support/gli_test_config.yml
|
274
|
-
- test/unit/switch_test.rb
|
275
|
-
- test/unit/terminal_test.rb
|
276
|
-
- test/unit/test_helper.rb
|
277
|
-
- test/unit/verbatim_wrapper_test.rb
|
231
|
+
test_files: []
|