gli 2.14.0 → 2.15.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/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +5 -3
- data/README.rdoc +9 -6
- data/features/gli_init.feature +0 -1
- data/features/todo.feature +23 -1
- data/gli.gemspec +8 -8
- data/lib/gli/command.rb +14 -0
- data/lib/gli/command_support.rb +5 -0
- data/lib/gli/commands/help_modules/command_help_format.rb +18 -0
- data/lib/gli/version.rb +1 -1
- data/test/apps/todo/lib/todo/commands/list.rb +8 -0
- metadata +30 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e666d683a83a5f81875fbe30821de7a7b13b831b
|
4
|
+
data.tar.gz: 466f1b67952cb0627da9918d1958df1306da1978
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82e0bde97f4d3813873fea67b1d3de567eb4c82faf82f89163a30c394f6a8f3220a65e60a39f437e772bf0e96c0ff29dfae140c73291cb18a547b34a4ad05744
|
7
|
+
data.tar.gz: a608c4252838fdd419d2ee53d08de948d6c56b2b70bbd3cd34d6fd3ef6d18d2e54374f042c34af77d7d238c98f45eade0215cf003ea46f1aa5d6e38f878b3683
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.1
|
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -75,13 +75,16 @@ Get a more detailed walkthrough on the {main site}[http://davetron5000.github.co
|
|
75
75
|
|
76
76
|
Tests should be passing supported MRI Rubies (see +.travis.yml+ for specifics).
|
77
77
|
|
78
|
-
Due to the vagaries of Travis, I can't keep the test suite running on unsupported Rubies,
|
78
|
+
Due to the vagaries of Travis, I can't keep the test suite running on unsupported Rubies, but we currently support:
|
79
|
+
|
80
|
+
* 2.1
|
81
|
+
* 2.2
|
82
|
+
* 2.3
|
83
|
+
* 2.4
|
84
|
+
* JRuby
|
85
|
+
|
86
|
+
GLI likely works on older rubies, but the cost of keeping tests passing on those versions (which are now totally unsupported by Ruby core) is too high.
|
79
87
|
|
80
|
-
* 1.8.7
|
81
|
-
* 1.9.2
|
82
|
-
* 1.9.3
|
83
|
-
* Ruby Enterprise Edition 1.8.7
|
84
|
-
* JRuby
|
85
88
|
|
86
89
|
== Documentation
|
87
90
|
|
data/features/gli_init.feature
CHANGED
data/features/todo.feature
CHANGED
@@ -211,6 +211,28 @@ Feature: The todo app has a nice user interface
|
|
211
211
|
| list --help |
|
212
212
|
| --help list |
|
213
213
|
|
214
|
+
Scenario: Getting Help for a leaf command of todo
|
215
|
+
Given todo's bin directory is in my path
|
216
|
+
When I successfully run `todo help list tasks open`
|
217
|
+
Then the output should contain:
|
218
|
+
"""
|
219
|
+
NAME
|
220
|
+
open - list open tasks
|
221
|
+
|
222
|
+
SYNOPSIS
|
223
|
+
todo [global options] list tasks open [command options]
|
224
|
+
|
225
|
+
COMMAND OPTIONS
|
226
|
+
--flag=arg - (default: none)
|
227
|
+
-x arg - blah blah crud x whatever (default: none)
|
228
|
+
|
229
|
+
EXAMPLES
|
230
|
+
|
231
|
+
# example number 1
|
232
|
+
todo list tasks open --flag=blah
|
233
|
+
|
234
|
+
todo list tasks open -x foo
|
235
|
+
"""
|
214
236
|
|
215
237
|
Scenario: Getting Help for a top level command of todo with no command options
|
216
238
|
When I successfully run `todo help chained`
|
@@ -315,7 +337,7 @@ Feature: The todo app has a nice user interface
|
|
315
337
|
|
316
338
|
SYNOPSIS
|
317
339
|
todo [global options] list tasks [command options] [task][, [task]]*
|
318
|
-
todo [global options] list tasks [command options] open
|
340
|
+
todo [global options] list tasks [command options] open [--flag arg] [-x arg]
|
319
341
|
|
320
342
|
DESCRIPTION
|
321
343
|
Lists all of your tasks that you have, in varying orders, and all that
|
data/gli.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Make sure we get the gli that's local
|
2
2
|
require File.join([File.dirname(__FILE__),'lib','gli','version.rb'])
|
3
3
|
|
4
|
-
spec = Gem::Specification.new do |s|
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
5
|
s.name = 'gli'
|
6
6
|
s.version = GLI::VERSION
|
7
|
+
s.licenses = ['Apache-2.0']
|
7
8
|
s.author = 'David Copeland'
|
8
9
|
s.email = 'davidcopeland@naildrivin5.com'
|
9
10
|
s.homepage = 'http://davetron5000.github.com/gli'
|
@@ -22,13 +23,12 @@ spec = Gem::Specification.new do |s|
|
|
22
23
|
s.bindir = 'bin'
|
23
24
|
s.rubyforge_project = 'gli'
|
24
25
|
s.add_development_dependency('rake', '~> 0.9.2.2')
|
25
|
-
s.add_development_dependency('rdoc')
|
26
|
-
s.add_development_dependency('rainbow', '~> 1.1.1')
|
27
|
-
s.add_development_dependency('clean_test')
|
28
|
-
s.add_development_dependency('cucumber')
|
29
|
-
s.add_development_dependency('gherkin')
|
26
|
+
s.add_development_dependency('rdoc', '~> 4.2')
|
27
|
+
s.add_development_dependency('rainbow', '~> 1.1', '~> 1.1.1')
|
28
|
+
s.add_development_dependency('clean_test', '~> 1.0')
|
29
|
+
s.add_development_dependency('cucumber', '~> 2.4')
|
30
|
+
s.add_development_dependency('gherkin', '~> 4.0')
|
30
31
|
s.add_development_dependency('aruba', '0.5.1')
|
31
|
-
s.add_development_dependency('sdoc')
|
32
|
+
s.add_development_dependency('sdoc', '~> 0.4')
|
32
33
|
s.add_development_dependency('faker','1.0.0')
|
33
34
|
end
|
34
|
-
|
data/lib/gli/command.rb
CHANGED
@@ -45,6 +45,8 @@ module GLI
|
|
45
45
|
# +skips_post+:: if true, this command advertises that it doesn't want the post block called after it
|
46
46
|
# +skips_around+:: if true, this command advertises that it doesn't want the around block called
|
47
47
|
# +hide_commands_without_desc+:: if true and there isn't a description the command is not going to be shown in the help
|
48
|
+
# +examples+:: An array of Hashes, where each hash must have the key +:example+ mapping to a string, and may optionally have the key +:desc+
|
49
|
+
# that documents that example.
|
48
50
|
def initialize(options)
|
49
51
|
super(options[:names],options[:description],options[:long_desc])
|
50
52
|
@arguments_description = options[:arguments_name] || ''
|
@@ -57,9 +59,21 @@ module GLI
|
|
57
59
|
@commands_declaration_order = []
|
58
60
|
@flags_declaration_order = []
|
59
61
|
@switches_declaration_order = []
|
62
|
+
@examples = options[:examples] || []
|
60
63
|
clear_nexts
|
61
64
|
end
|
62
65
|
|
66
|
+
# Specify an example invocation.
|
67
|
+
#
|
68
|
+
# example_invocation:: test of a complete command-line invocation you want to show
|
69
|
+
# options:: refine the example:
|
70
|
+
# +:desc+:: A description of the example to be shown with it (optional)
|
71
|
+
def example(example_invocation,options = {})
|
72
|
+
@examples << {
|
73
|
+
example: example_invocation
|
74
|
+
}.merge(options)
|
75
|
+
end
|
76
|
+
|
63
77
|
# Set the default command if this command has subcommands and the user doesn't
|
64
78
|
# provide a subcommand when invoking THIS command. When nil, this will show an error and the help
|
65
79
|
# for this command; when set, the command with this name will be executed.
|
data/lib/gli/command_support.rb
CHANGED
@@ -18,6 +18,7 @@ module GLI
|
|
18
18
|
|
19
19
|
options_description = OptionsFormatter.new(flags_and_switches(@command,@app),@sorter,@wrapper_class).format
|
20
20
|
commands_description = format_subcommands(@command)
|
21
|
+
command_examples = format_examples(@command)
|
21
22
|
|
22
23
|
synopses = @synopsis_formatter.synopses_for_command(@command)
|
23
24
|
COMMAND_HELP.result(binding)
|
@@ -45,6 +46,13 @@ COMMAND OPTIONS
|
|
45
46
|
|
46
47
|
COMMANDS
|
47
48
|
<%= commands_description %>
|
49
|
+
<% end %>
|
50
|
+
<% unless @command.examples.empty? %>
|
51
|
+
|
52
|
+
<%= @command.examples.size == 1 ? 'EXAMPLE' : 'EXAMPLES' %>
|
53
|
+
|
54
|
+
|
55
|
+
<%= command_examples %>
|
48
56
|
<% end %>),nil,'<>')
|
49
57
|
|
50
58
|
|
@@ -76,6 +84,16 @@ COMMANDS
|
|
76
84
|
formatter = ListFormatter.new(commands_array,@wrapper_class)
|
77
85
|
StringIO.new.tap { |io| formatter.output(io) }.string
|
78
86
|
end
|
87
|
+
|
88
|
+
def format_examples(command)
|
89
|
+
command.examples.map {|example|
|
90
|
+
string = ""
|
91
|
+
if example[:desc]
|
92
|
+
string << " # #{example[:desc]}\n"
|
93
|
+
end
|
94
|
+
string << " #{example.fetch(:example)}\n"
|
95
|
+
}.join("\n")
|
96
|
+
end
|
79
97
|
end
|
80
98
|
end
|
81
99
|
end
|
data/lib/gli/version.rb
CHANGED
@@ -38,6 +38,14 @@ command [:list] do |c|
|
|
38
38
|
|
39
39
|
tasks.desc 'list open tasks'
|
40
40
|
tasks.command :open do |open|
|
41
|
+
open.desc "blah blah crud x whatever"
|
42
|
+
open.flag [:x], :must_match => Array
|
43
|
+
|
44
|
+
open.flag :flag
|
45
|
+
|
46
|
+
open.example "todo list tasks open --flag=blah", desc: "example number 1"
|
47
|
+
open.example "todo list tasks open -x foo"
|
48
|
+
|
41
49
|
open.action do |global,options,args|
|
42
50
|
puts "tasks open"
|
43
51
|
end
|
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.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Copeland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -28,20 +28,23 @@ dependencies:
|
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rainbow
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.1'
|
45
48
|
- - "~>"
|
46
49
|
- !ruby/object:Gem::Version
|
47
50
|
version: 1.1.1
|
@@ -49,6 +52,9 @@ dependencies:
|
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '1.1'
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: 1.1.1
|
@@ -56,44 +62,44 @@ dependencies:
|
|
56
62
|
name: clean_test
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
67
|
+
version: '1.0'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- - "
|
72
|
+
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
74
|
+
version: '1.0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: cucumber
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- - "
|
79
|
+
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
81
|
+
version: '2.4'
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
|
-
- - "
|
86
|
+
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
88
|
+
version: '2.4'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: gherkin
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
|
-
- - "
|
93
|
+
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
95
|
+
version: '4.0'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
|
-
- - "
|
100
|
+
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
102
|
+
version: '4.0'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: aruba
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,16 +118,16 @@ dependencies:
|
|
112
118
|
name: sdoc
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
114
120
|
requirements:
|
115
|
-
- - "
|
121
|
+
- - "~>"
|
116
122
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
123
|
+
version: '0.4'
|
118
124
|
type: :development
|
119
125
|
prerelease: false
|
120
126
|
version_requirements: !ruby/object:Gem::Requirement
|
121
127
|
requirements:
|
122
|
-
- - "
|
128
|
+
- - "~>"
|
123
129
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
130
|
+
version: '0.4'
|
125
131
|
- !ruby/object:Gem::Dependency
|
126
132
|
name: faker
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,7 +261,8 @@ files:
|
|
255
261
|
- test/tc_verbatim_wrapper.rb
|
256
262
|
- test/test_helper.rb
|
257
263
|
homepage: http://davetron5000.github.com/gli
|
258
|
-
licenses:
|
264
|
+
licenses:
|
265
|
+
- Apache-2.0
|
259
266
|
metadata: {}
|
260
267
|
post_install_message:
|
261
268
|
rdoc_options:
|