gli 2.9.0 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +28 -0
- data/.gitignore +3 -3
- data/.tool-versions +1 -0
- data/Gemfile +0 -2
- data/README.rdoc +29 -18
- data/Rakefile +15 -37
- data/bin/ci +29 -0
- data/bin/gli +24 -54
- data/bin/rake +29 -0
- data/bin/setup +5 -0
- data/exe/gli +68 -0
- data/gli.gemspec +20 -24
- data/gli.rdoc +9 -9
- data/lib/gli/app.rb +42 -8
- data/lib/gli/app_support.rb +17 -5
- data/lib/gli/argument.rb +20 -0
- data/lib/gli/command.rb +27 -2
- data/lib/gli/command_finder.rb +42 -25
- data/lib/gli/command_support.rb +13 -7
- data/lib/gli/commands/doc.rb +9 -3
- data/lib/gli/commands/help.rb +2 -1
- data/lib/gli/commands/help_modules/arg_name_formatter.rb +29 -2
- data/lib/gli/commands/help_modules/command_help_format.rb +19 -1
- data/lib/gli/commands/help_modules/full_synopsis_formatter.rb +5 -4
- data/lib/gli/commands/help_modules/global_help_format.rb +1 -1
- data/lib/gli/commands/help_modules/options_formatter.rb +4 -6
- data/lib/gli/commands/initconfig.rb +3 -6
- data/lib/gli/commands/rdoc_document_listener.rb +2 -1
- data/lib/gli/commands/scaffold.rb +71 -142
- data/lib/gli/dsl.rb +25 -1
- data/lib/gli/exceptions.rb +26 -0
- data/lib/gli/flag.rb +23 -2
- data/lib/gli/gli_option_parser.rb +73 -21
- data/lib/gli/option_parser_factory.rb +10 -3
- data/lib/gli/options.rb +2 -2
- data/lib/gli/switch.rb +4 -0
- data/lib/gli/terminal.rb +6 -2
- data/lib/gli/version.rb +1 -1
- data/lib/gli.rb +2 -0
- data/object-model.dot +29 -0
- data/object-model.png +0 -0
- data/test/apps/todo/Gemfile +1 -1
- data/test/apps/todo/bin/todo +16 -6
- data/test/apps/todo/lib/todo/commands/create.rb +48 -18
- data/test/apps/todo/lib/todo/commands/list.rb +48 -35
- data/test/apps/todo/lib/todo/commands/ls.rb +25 -24
- data/test/apps/todo/lib/todo/commands/make.rb +42 -39
- data/test/apps/todo/todo.gemspec +1 -2
- data/test/apps/todo_legacy/todo.gemspec +1 -2
- data/test/apps/todo_plugins/commands/third.rb +2 -0
- data/test/integration/gli_cli_test.rb +69 -0
- data/test/integration/gli_powered_app_test.rb +52 -0
- data/test/integration/scaffold_test.rb +30 -0
- data/test/integration/test_helper.rb +52 -0
- data/test/unit/command_finder_test.rb +54 -0
- data/test/{tc_command.rb → unit/command_test.rb} +20 -7
- data/test/unit/compound_command_test.rb +17 -0
- data/test/{tc_doc.rb → unit/doc_test.rb} +38 -51
- data/test/{tc_flag.rb → unit/flag_test.rb} +19 -25
- data/test/{tc_gli.rb → unit/gli_test.rb} +92 -49
- data/test/{tc_help.rb → unit/help_test.rb} +54 -113
- data/test/{init_simplecov.rb → unit/init_simplecov.rb} +0 -0
- data/test/{tc_options.rb → unit/options_test.rb} +4 -4
- data/test/unit/subcommand_parsing_test.rb +263 -0
- data/test/unit/subcommands_test.rb +245 -0
- data/test/{fake_std_out.rb → unit/support/fake_std_out.rb} +0 -0
- data/test/{config.yaml → unit/support/gli_test_config.yml} +1 -0
- data/test/unit/switch_test.rb +49 -0
- data/test/{tc_terminal.rb → unit/terminal_test.rb} +28 -3
- data/test/unit/test_helper.rb +13 -0
- data/test/unit/verbatim_wrapper_test.rb +24 -0
- metadata +86 -141
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -12
- data/ObjectModel.graffle +0 -1191
- data/bin/report_on_rake_results +0 -10
- data/bin/test_all_rubies.sh +0 -6
- data/features/gli_executable.feature +0 -90
- data/features/gli_init.feature +0 -232
- data/features/step_definitions/gli_executable_steps.rb +0 -18
- data/features/step_definitions/gli_init_steps.rb +0 -11
- data/features/step_definitions/todo_steps.rb +0 -96
- data/features/support/env.rb +0 -54
- data/features/todo.feature +0 -449
- data/features/todo_legacy.feature +0 -128
- data/test/option_test_helper.rb +0 -13
- data/test/tc_compound_command.rb +0 -22
- data/test/tc_subcommand_parsing.rb +0 -104
- data/test/tc_subcommands.rb +0 -259
- data/test/tc_switch.rb +0 -55
- data/test/tc_verbatim_wrapper.rb +0 -36
- data/test/test_helper.rb +0 -20
data/features/todo.feature
DELETED
@@ -1,449 +0,0 @@
|
|
1
|
-
Feature: The todo app has a nice user interface
|
2
|
-
As a user of the todo application
|
3
|
-
It should have a nice UI, since it's GLI-powered
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given I have GLI installed
|
7
|
-
And GLI's libs are in my path
|
8
|
-
And my terminal size is "80x24"
|
9
|
-
And todo's bin directory is in my path
|
10
|
-
|
11
|
-
Scenario: Error message for unknown command
|
12
|
-
When I run `todo help unknown`
|
13
|
-
Then the output should contain:
|
14
|
-
"""
|
15
|
-
error: Unknown command 'unknown'. Use 'todo help' for a list of commands.
|
16
|
-
"""
|
17
|
-
|
18
|
-
Scenario Outline: Getting Help for todo in general
|
19
|
-
When I successfully run `todo <help>`
|
20
|
-
Then the output should contain:
|
21
|
-
"""
|
22
|
-
NAME
|
23
|
-
todo - Manages tasks
|
24
|
-
|
25
|
-
A test program that has a sophisticated UI that can be used to exercise a
|
26
|
-
lot of GLI's power
|
27
|
-
|
28
|
-
SYNOPSIS
|
29
|
-
todo [global options] command [command options] [arguments...]
|
30
|
-
|
31
|
-
VERSION
|
32
|
-
0.0.1
|
33
|
-
|
34
|
-
GLOBAL OPTIONS
|
35
|
-
--flag=arg - (default: none)
|
36
|
-
--help - Show this message
|
37
|
-
--[no-]otherswitch -
|
38
|
-
--[no-]switch -
|
39
|
-
--version - Display the program version
|
40
|
-
|
41
|
-
COMMANDS
|
42
|
-
chained -
|
43
|
-
chained2, ch2 -
|
44
|
-
create, new - Create a new task or context
|
45
|
-
first -
|
46
|
-
help - Shows a list of commands or help for one command
|
47
|
-
initconfig - Initialize the config file using current global options
|
48
|
-
list - List things, such as tasks or contexts
|
49
|
-
ls - LS things, such as tasks or contexts
|
50
|
-
make -
|
51
|
-
second -
|
52
|
-
third -
|
53
|
-
"""
|
54
|
-
Examples:
|
55
|
-
| help |
|
56
|
-
| help |
|
57
|
-
|
58
|
-
Scenario: Version display
|
59
|
-
When I successfully run `todo --version`
|
60
|
-
Then the output should contain:
|
61
|
-
"""
|
62
|
-
todo version 0.0.1
|
63
|
-
"""
|
64
|
-
|
65
|
-
Scenario: Help completion mode
|
66
|
-
When I successfully run `todo help -c`
|
67
|
-
Then the output should contain:
|
68
|
-
"""
|
69
|
-
_doc
|
70
|
-
ch2
|
71
|
-
chained
|
72
|
-
chained2
|
73
|
-
create
|
74
|
-
first
|
75
|
-
help
|
76
|
-
initconfig
|
77
|
-
list
|
78
|
-
ls
|
79
|
-
make
|
80
|
-
new
|
81
|
-
second
|
82
|
-
third
|
83
|
-
"""
|
84
|
-
|
85
|
-
Scenario: Help completion mode for partial match
|
86
|
-
When I successfully run `todo help -c ch`
|
87
|
-
Then the output should contain:
|
88
|
-
"""
|
89
|
-
ch2
|
90
|
-
chained
|
91
|
-
chained2
|
92
|
-
"""
|
93
|
-
|
94
|
-
Scenario: Help completion mode for subcommands
|
95
|
-
When I successfully run `todo help -c list`
|
96
|
-
Then the output should contain:
|
97
|
-
"""
|
98
|
-
contexts
|
99
|
-
tasks
|
100
|
-
"""
|
101
|
-
|
102
|
-
Scenario: Help completion mode partial match for subcommands
|
103
|
-
When I successfully run `todo help -c list con`
|
104
|
-
Then the output should contain:
|
105
|
-
"""
|
106
|
-
contexts
|
107
|
-
"""
|
108
|
-
|
109
|
-
Scenario: Getting Help with self-ordered commands
|
110
|
-
Given the todo app is coded to avoid sorted help commands
|
111
|
-
When I successfully run `todo help`
|
112
|
-
Then the output should contain:
|
113
|
-
"""
|
114
|
-
NAME
|
115
|
-
todo - Manages tasks
|
116
|
-
|
117
|
-
A test program that has a sophisticated UI that can be used to exercise a
|
118
|
-
lot of GLI's power
|
119
|
-
|
120
|
-
SYNOPSIS
|
121
|
-
todo [global options] command [command options] [arguments...]
|
122
|
-
|
123
|
-
VERSION
|
124
|
-
0.0.1
|
125
|
-
|
126
|
-
GLOBAL OPTIONS
|
127
|
-
--flag=arg - (default: none)
|
128
|
-
--[no-]switch -
|
129
|
-
--[no-]otherswitch -
|
130
|
-
--version - Display the program version
|
131
|
-
--help - Show this message
|
132
|
-
|
133
|
-
COMMANDS
|
134
|
-
help - Shows a list of commands or help for one command
|
135
|
-
initconfig - Initialize the config file using current global options
|
136
|
-
create, new - Create a new task or context
|
137
|
-
list - List things, such as tasks or contexts
|
138
|
-
ls - LS things, such as tasks or contexts
|
139
|
-
make -
|
140
|
-
third -
|
141
|
-
first -
|
142
|
-
second -
|
143
|
-
chained -
|
144
|
-
chained2, ch2 -
|
145
|
-
"""
|
146
|
-
|
147
|
-
Scenario Outline: Getting Help for a top level command of todo
|
148
|
-
When I successfully run `todo <help_invocation>`
|
149
|
-
Then the output should contain:
|
150
|
-
"""
|
151
|
-
NAME
|
152
|
-
list - List things, such as tasks or contexts
|
153
|
-
|
154
|
-
SYNOPSIS
|
155
|
-
todo [global options] list [command options] [tasks] [--flag arg] [-x arg]
|
156
|
-
todo [global options] list [command options] contexts [--otherflag arg] [-b] [-f|--foobar]
|
157
|
-
|
158
|
-
DESCRIPTION
|
159
|
-
List a whole lot of things that you might be keeping track of in your
|
160
|
-
overall todo list.
|
161
|
-
|
162
|
-
This is your go-to place or finding all of the things that you might have
|
163
|
-
stored in your todo databases.
|
164
|
-
|
165
|
-
COMMAND OPTIONS
|
166
|
-
-l, --[no-]long - Show long form
|
167
|
-
--required_flag=arg - (required, default: none)
|
168
|
-
|
169
|
-
COMMANDS
|
170
|
-
contexts - List contexts
|
171
|
-
tasks - List tasks (default)
|
172
|
-
"""
|
173
|
-
|
174
|
-
Examples:
|
175
|
-
| help_invocation |
|
176
|
-
| help list |
|
177
|
-
| list -h |
|
178
|
-
| list --help |
|
179
|
-
| --help list |
|
180
|
-
|
181
|
-
|
182
|
-
Scenario: Getting Help for a top level command of todo with no command options
|
183
|
-
When I successfully run `todo help chained`
|
184
|
-
Then the output should contain:
|
185
|
-
"""
|
186
|
-
NAME
|
187
|
-
chained -
|
188
|
-
|
189
|
-
SYNOPSIS
|
190
|
-
todo [global options] chained
|
191
|
-
"""
|
192
|
-
|
193
|
-
Scenario: Getting Help with no wrapping
|
194
|
-
Given the todo app is coded to avoid wrapping text
|
195
|
-
When I successfully run `todo help list`
|
196
|
-
Then the output should contain:
|
197
|
-
"""
|
198
|
-
NAME
|
199
|
-
list - List things, such as tasks or contexts
|
200
|
-
|
201
|
-
SYNOPSIS
|
202
|
-
todo [global options] list [command options] [tasks] [--flag arg] [-x arg]
|
203
|
-
todo [global options] list [command options] contexts [--otherflag arg] [-b] [-f|--foobar]
|
204
|
-
|
205
|
-
DESCRIPTION
|
206
|
-
List a whole lot of things that you might be keeping track of in your overall todo list. This is your go-to place or finding all of the things that you might have stored in your todo databases.
|
207
|
-
|
208
|
-
COMMAND OPTIONS
|
209
|
-
-l, --[no-]long - Show long form
|
210
|
-
--required_flag=arg - (required, default: none)
|
211
|
-
|
212
|
-
COMMANDS
|
213
|
-
contexts - List contexts
|
214
|
-
tasks - List tasks (default)
|
215
|
-
"""
|
216
|
-
|
217
|
-
Scenario: Getting Help with verbatim formatting
|
218
|
-
Given the todo app is coded to use verbatim formatting
|
219
|
-
When I successfully run `todo help list`
|
220
|
-
Then the output should contain:
|
221
|
-
"""
|
222
|
-
NAME
|
223
|
-
list - List things, such as tasks or contexts
|
224
|
-
|
225
|
-
SYNOPSIS
|
226
|
-
todo [global options] list [command options] [tasks] [--flag arg] [-x arg]
|
227
|
-
todo [global options] list [command options] contexts [--otherflag arg] [-b] [-f|--foobar]
|
228
|
-
|
229
|
-
DESCRIPTION
|
230
|
-
|
231
|
-
List a whole lot of things that you might be keeping track of
|
232
|
-
in your overall todo list.
|
233
|
-
|
234
|
-
This is your go-to place or finding all of the things that you
|
235
|
-
might have
|
236
|
-
stored in
|
237
|
-
your todo databases.
|
238
|
-
|
239
|
-
|
240
|
-
COMMAND OPTIONS
|
241
|
-
-l, --[no-]long - Show long form
|
242
|
-
--required_flag=arg - (required, default: none)
|
243
|
-
|
244
|
-
COMMANDS
|
245
|
-
contexts - List contexts
|
246
|
-
tasks - List tasks (default)
|
247
|
-
"""
|
248
|
-
|
249
|
-
Scenario: Getting Help without wrapping
|
250
|
-
Given the todo app is coded to wrap text only for tty
|
251
|
-
When I successfully run `todo help list`
|
252
|
-
Then the output should contain:
|
253
|
-
"""
|
254
|
-
NAME
|
255
|
-
list - List things, such as tasks or contexts
|
256
|
-
|
257
|
-
SYNOPSIS
|
258
|
-
todo [global options] list [command options] [tasks] [--flag arg] [-x arg]
|
259
|
-
todo [global options] list [command options] contexts [--otherflag arg] [-b] [-f|--foobar]
|
260
|
-
|
261
|
-
DESCRIPTION
|
262
|
-
List a whole lot of things that you might be keeping track of in your overall todo list. This is your go-to place or finding all of the things that you might have stored in your todo databases.
|
263
|
-
|
264
|
-
COMMAND OPTIONS
|
265
|
-
-l, --[no-]long - Show long form
|
266
|
-
--required_flag=arg - (required, default: none)
|
267
|
-
|
268
|
-
COMMANDS
|
269
|
-
contexts - List contexts
|
270
|
-
tasks - List tasks (default)
|
271
|
-
"""
|
272
|
-
|
273
|
-
Scenario: Getting Help for a sub command of todo list
|
274
|
-
When I successfully run `todo help list tasks`
|
275
|
-
Then the output should contain:
|
276
|
-
"""
|
277
|
-
NAME
|
278
|
-
tasks - List tasks
|
279
|
-
|
280
|
-
SYNOPSIS
|
281
|
-
todo [global options] list tasks [command options]
|
282
|
-
todo [global options] list tasks [command options] open
|
283
|
-
|
284
|
-
DESCRIPTION
|
285
|
-
Lists all of your tasks that you have, in varying orders, and all that
|
286
|
-
stuff. Yes, this is long, but I need a long description.
|
287
|
-
|
288
|
-
COMMAND OPTIONS
|
289
|
-
--flag=arg - (default: none)
|
290
|
-
-x arg - blah blah crud x whatever (default: none)
|
291
|
-
|
292
|
-
COMMANDS
|
293
|
-
<default> - list all tasks
|
294
|
-
open - list open tasks
|
295
|
-
"""
|
296
|
-
|
297
|
-
Scenario: Getting Help for a sub command with no command options
|
298
|
-
When I successfully run `todo help new`
|
299
|
-
Then the output should contain:
|
300
|
-
"""
|
301
|
-
NAME
|
302
|
-
create - Create a new task or context
|
303
|
-
|
304
|
-
SYNOPSIS
|
305
|
-
todo [global options] create
|
306
|
-
todo [global options] create contexts [context_name]
|
307
|
-
todo [global options] create tasks task_name[, task_name]*
|
308
|
-
|
309
|
-
COMMANDS
|
310
|
-
<default> - Makes a new task
|
311
|
-
contexts - Make a new context
|
312
|
-
tasks - Make a new task
|
313
|
-
"""
|
314
|
-
And the output should not contain "COMMAND OPTIONS"
|
315
|
-
|
316
|
-
Scenario: Running list w/out subcommand performs list tasks by default
|
317
|
-
When I successfully run `todo list --required_flag=blah boo yay`
|
318
|
-
Then the output should contain "list tasks: boo,yay"
|
319
|
-
|
320
|
-
Scenario: Running list w/out subcommand or any arguments performs list tasks by default
|
321
|
-
When I successfully run `todo list --required_flag=blah`
|
322
|
-
Then the output should contain "list tasks:"
|
323
|
-
|
324
|
-
Scenario: Running chained commands works
|
325
|
-
When I successfully run `todo chained foo bar`
|
326
|
-
Then the output should contain:
|
327
|
-
"""
|
328
|
-
first: foo,bar
|
329
|
-
second: foo,bar
|
330
|
-
"""
|
331
|
-
|
332
|
-
Scenario: Running chained commands works and is ordered
|
333
|
-
When I successfully run `todo chained2 foo bar`
|
334
|
-
Then the output should contain:
|
335
|
-
"""
|
336
|
-
second: foo,bar
|
337
|
-
first: foo,bar
|
338
|
-
"""
|
339
|
-
|
340
|
-
Scenario: Running chained commands works and is ordered
|
341
|
-
When I successfully run `todo ch2 foo bar`
|
342
|
-
Then the output should contain:
|
343
|
-
"""
|
344
|
-
second: foo,bar
|
345
|
-
first: foo,bar
|
346
|
-
"""
|
347
|
-
|
348
|
-
Scenario: Running ls w/out subcommand shows help and an error
|
349
|
-
When I run `todo ls`
|
350
|
-
Then the exit status should not be 0
|
351
|
-
And the stderr should contain "error: Command 'ls' requires a subcommand"
|
352
|
-
And the stdout should contain:
|
353
|
-
"""
|
354
|
-
NAME
|
355
|
-
ls - LS things, such as tasks or contexts
|
356
|
-
|
357
|
-
SYNOPSIS
|
358
|
-
todo [global options] ls [command options] contexts [-b] [-f|--foobar]
|
359
|
-
todo [global options] ls [command options] tasks [-x arg]
|
360
|
-
|
361
|
-
DESCRIPTION
|
362
|
-
List a whole lot of things that you might be keeping track of in your
|
363
|
-
overall todo list.
|
364
|
-
|
365
|
-
This is your go-to place or finding all of the things that you might have
|
366
|
-
stored in your todo databases.
|
367
|
-
|
368
|
-
COMMAND OPTIONS
|
369
|
-
-l, --[no-]long - Show long form
|
370
|
-
|
371
|
-
COMMANDS
|
372
|
-
contexts - List contexts
|
373
|
-
tasks - List tasks
|
374
|
-
"""
|
375
|
-
|
376
|
-
Scenario: Access to the complex command-line options for nested subcommands
|
377
|
-
Given I run `todo make -l MAKE task -l TASK bug -l BUG other args`
|
378
|
-
Then the exit status should be 0
|
379
|
-
And the stdout should contain:
|
380
|
-
"""
|
381
|
-
new task bug
|
382
|
-
other,args
|
383
|
-
BUG
|
384
|
-
|
385
|
-
BUG
|
386
|
-
TASK
|
387
|
-
TASK
|
388
|
-
|
389
|
-
MAKE
|
390
|
-
MAKE
|
391
|
-
|
392
|
-
"""
|
393
|
-
|
394
|
-
Scenario: Init Config makes a reasonable config file
|
395
|
-
Given a clean home directory
|
396
|
-
When I successfully run `todo --flag foo --switch --no-otherswitch initconfig`
|
397
|
-
Then the config file should contain a section for each command and subcommand
|
398
|
-
|
399
|
-
Scenario: Init Config makes a reasonable config file if one is there and we force it
|
400
|
-
Given a clean home directory
|
401
|
-
And I successfully run `todo --flag foo --switch --no-otherswitch initconfig`
|
402
|
-
When I run `todo --flag foo --switch --no-otherswitch initconfig`
|
403
|
-
Then the exit status should not be 0
|
404
|
-
When I run `todo --flag foo --switch --no-otherswitch initconfig --force`
|
405
|
-
Then the exit status should be 0
|
406
|
-
|
407
|
-
Scenario: Configuration percolates to the app
|
408
|
-
Given a clean home directory
|
409
|
-
And a config file that specifies defaults for some commands with subcommands
|
410
|
-
When I successfully run `todo help list tasks`
|
411
|
-
Then I should see the defaults for 'list tasks' from the config file in the help
|
412
|
-
|
413
|
-
Scenario: Do it again because aruba buffers all output
|
414
|
-
Given a clean home directory
|
415
|
-
And a config file that specifies defaults for some commands with subcommands
|
416
|
-
When I successfully run `todo help list contexts`
|
417
|
-
Then I should see the defaults for 'list contexts' from the config file in the help
|
418
|
-
|
419
|
-
Scenario: A complex SYNOPSIS section gets summarized in terminal mode
|
420
|
-
Given my terminal is 50 characters wide
|
421
|
-
And my app is configured for "terminal" synopses
|
422
|
-
When I run `todo ls`
|
423
|
-
Then the exit status should not be 0
|
424
|
-
And the stderr should contain "error: Command 'ls' requires a subcommand"
|
425
|
-
And the stdout should contain:
|
426
|
-
"""
|
427
|
-
NAME
|
428
|
-
ls - LS things, such as tasks or contexts
|
429
|
-
|
430
|
-
SYNOPSIS
|
431
|
-
todo [global options] ls [command options] contexts [subcommand options]
|
432
|
-
todo [global options] ls [command options] tasks [subcommand options]
|
433
|
-
"""
|
434
|
-
|
435
|
-
Scenario: We can always use a compact SYNOPSIS
|
436
|
-
Given my terminal is 500 characters wide
|
437
|
-
And my app is configured for "compact" synopses
|
438
|
-
When I run `todo ls`
|
439
|
-
Then the exit status should not be 0
|
440
|
-
And the stderr should contain "error: Command 'ls' requires a subcommand"
|
441
|
-
And the stdout should contain:
|
442
|
-
"""
|
443
|
-
NAME
|
444
|
-
ls - LS things, such as tasks or contexts
|
445
|
-
|
446
|
-
SYNOPSIS
|
447
|
-
todo [global options] ls [command options] contexts [subcommand options]
|
448
|
-
todo [global options] ls [command options] tasks [subcommand options]
|
449
|
-
"""
|
@@ -1,128 +0,0 @@
|
|
1
|
-
Feature: The todo app is backwards compatible with legacy subcommand parsing
|
2
|
-
As a user of GLI
|
3
|
-
My apps with subcommands should support the old, legacy way, by default
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given I have GLI installed
|
7
|
-
And GLI's libs are in my path
|
8
|
-
And my terminal size is "80x24"
|
9
|
-
And todo_legacy's bin directory is in my path
|
10
|
-
|
11
|
-
Scenario: Help completion mode for subcommands
|
12
|
-
When I successfully run `todo help -c list`
|
13
|
-
Then the output should contain:
|
14
|
-
"""
|
15
|
-
contexts
|
16
|
-
tasks
|
17
|
-
"""
|
18
|
-
|
19
|
-
Scenario: Help completion mode partial match for subcommands
|
20
|
-
When I successfully run `todo help -c list con`
|
21
|
-
Then the output should contain:
|
22
|
-
"""
|
23
|
-
contexts
|
24
|
-
"""
|
25
|
-
|
26
|
-
Scenario Outline: Getting Help for a top level command of todo
|
27
|
-
When I successfully run `todo <help_invocation>`
|
28
|
-
Then the output should contain:
|
29
|
-
"""
|
30
|
-
NAME
|
31
|
-
list - List things, such as tasks or contexts
|
32
|
-
|
33
|
-
SYNOPSIS
|
34
|
-
todo [global options] list [command options] [tasks] [--flag arg] [-x arg]
|
35
|
-
todo [global options] list [command options] contexts [--otherflag arg] [-b] [-f|--foobar]
|
36
|
-
|
37
|
-
DESCRIPTION
|
38
|
-
List a whole lot of things that you might be keeping track of in your
|
39
|
-
overall todo list.
|
40
|
-
|
41
|
-
This is your go-to place or finding all of the things that you might have
|
42
|
-
stored in your todo databases.
|
43
|
-
|
44
|
-
COMMAND OPTIONS
|
45
|
-
-l, --[no-]long - Show long form
|
46
|
-
|
47
|
-
COMMANDS
|
48
|
-
contexts - List contexts
|
49
|
-
tasks - List tasks (default)
|
50
|
-
"""
|
51
|
-
|
52
|
-
Examples:
|
53
|
-
| help_invocation |
|
54
|
-
| help list |
|
55
|
-
| list -h |
|
56
|
-
| list --help |
|
57
|
-
|
58
|
-
|
59
|
-
Scenario: Getting Help for a sub command of todo list
|
60
|
-
When I successfully run `todo help list tasks`
|
61
|
-
Then the output should contain:
|
62
|
-
"""
|
63
|
-
NAME
|
64
|
-
tasks - List tasks
|
65
|
-
|
66
|
-
SYNOPSIS
|
67
|
-
todo [global options] list tasks [command options]
|
68
|
-
todo [global options] list tasks [command options] open
|
69
|
-
|
70
|
-
DESCRIPTION
|
71
|
-
Lists all of your tasks that you have, in varying orders, and all that
|
72
|
-
stuff. Yes, this is long, but I need a long description.
|
73
|
-
|
74
|
-
COMMAND OPTIONS
|
75
|
-
--flag=arg - (default: none)
|
76
|
-
-x arg - blah blah crud x whatever (default: none)
|
77
|
-
|
78
|
-
COMMANDS
|
79
|
-
<default> - list all tasks
|
80
|
-
open - list open tasks
|
81
|
-
"""
|
82
|
-
|
83
|
-
Scenario: Getting Help for a sub command with no command options
|
84
|
-
When I successfully run `todo help new`
|
85
|
-
Then the output should contain:
|
86
|
-
"""
|
87
|
-
NAME
|
88
|
-
create - Create a new task or context
|
89
|
-
|
90
|
-
SYNOPSIS
|
91
|
-
todo [global options] create
|
92
|
-
todo [global options] create contexts [context_name]
|
93
|
-
todo [global options] create tasks task_name[, task_name]*
|
94
|
-
|
95
|
-
COMMANDS
|
96
|
-
<default> - Makes a new task
|
97
|
-
contexts - Make a new context
|
98
|
-
tasks - Make a new task
|
99
|
-
"""
|
100
|
-
And the output should not contain "COMMAND OPTIONS"
|
101
|
-
|
102
|
-
Scenario: Running ls w/out subcommand shows help and an error
|
103
|
-
When I run `todo ls`
|
104
|
-
Then the exit status should not be 0
|
105
|
-
And the stderr should contain "error: Command 'ls' requires a subcommand"
|
106
|
-
And the stdout should contain:
|
107
|
-
"""
|
108
|
-
NAME
|
109
|
-
ls - LS things, such as tasks or contexts
|
110
|
-
|
111
|
-
SYNOPSIS
|
112
|
-
todo [global options] ls [command options] contexts [-b] [-f|--foobar]
|
113
|
-
todo [global options] ls [command options] tasks [-x arg]
|
114
|
-
|
115
|
-
DESCRIPTION
|
116
|
-
List a whole lot of things that you might be keeping track of in your
|
117
|
-
overall todo list.
|
118
|
-
|
119
|
-
This is your go-to place or finding all of the things that you might have
|
120
|
-
stored in your todo databases.
|
121
|
-
|
122
|
-
COMMAND OPTIONS
|
123
|
-
-l, --[no-]long - Show long form
|
124
|
-
|
125
|
-
COMMANDS
|
126
|
-
contexts - List contexts
|
127
|
-
tasks - List tasks
|
128
|
-
"""
|
data/test/option_test_helper.rb
DELETED
data/test/tc_compound_command.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'tempfile'
|
3
|
-
|
4
|
-
class TC_testCompounCommand < Clean::Test::TestCase
|
5
|
-
include TestHelper
|
6
|
-
|
7
|
-
test_that "when we create a CompoundCommand where some commands are missing, we get an exception" do
|
8
|
-
Given {
|
9
|
-
@name = any_string
|
10
|
-
@unknown_name = any_string
|
11
|
-
@existing_command = OpenStruct.new(:name => @name)
|
12
|
-
@base = OpenStruct.new( :commands => { @name => @existing_command })
|
13
|
-
}
|
14
|
-
When {
|
15
|
-
@code = lambda { GLI::Commands::CompoundCommand.new(@base,{:foo => [@name,@unknown_name]}) }
|
16
|
-
}
|
17
|
-
Then {
|
18
|
-
ex = assert_raises(RuntimeError,&@code)
|
19
|
-
assert_match /#{@unknown_name}/,ex.message
|
20
|
-
}
|
21
|
-
end
|
22
|
-
end
|