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