45
45
__doc__ = """A sample command."""
46
46
_see_also = ['foo', 'bar']
47
47
self.assertCmdHelp('''\
48
Purpose: A sample command.
49
Usage: bzr WithSeeAlso
52
--usage Show usage message and options.
53
-v, --verbose Display more information.
54
-q, --quiet Only display errors and warnings.
55
-h, --help Show help message.
48
Purpose: A sample command.
49
Usage: bzr WithSeeAlso
52
-O ARG, --override-config=ARG
53
Override a configuration option value, e.g.
55
--usage Show usage message and options.
56
-q, --quiet Only display errors and warnings.
57
-v, --verbose Display more information.
58
-h, --help Show help message.
61
64
def test_get_help_text(self):
63
66
class cmd_Demo(commands.Command):
64
67
__doc__ = """A sample command."""
65
68
self.assertCmdHelp('''\
66
Purpose: A sample command.
70
--usage Show usage message and options.
71
-v, --verbose Display more information.
72
-q, --quiet Only display errors and warnings.
73
-h, --help Show help message.
69
Purpose: A sample command.
73
-O ARG, --override-config=ARG
74
Override a configuration option value, e.g.
76
--usage Show usage message and options.
77
-q, --quiet Only display errors and warnings.
78
-v, --verbose Display more information.
79
-h, --help Show help message.
78
84
helptext = cmd.get_help_text()
90
96
helptext = cmd.get_help_text(['gam'])
91
97
self.assertEndsWith(
93
' -v, --verbose Display more information.\n'
94
' -q, --quiet Only display errors and warnings.\n'
95
' -h, --help Show help message.\n'
99
' -q, --quiet Only display errors and warnings.\n'
100
' -v, --verbose Display more information.\n'
101
' -h, --help Show help message.\n'
97
103
'See also: bar, foo, gam\n')
140
146
helptext = cmd.get_help_text()
143
'Purpose: A sample command.\n'
147
' --usage Show usage message and options.\n'
148
' -v, --verbose Display more information.\n'
149
' -q, --quiet Only display errors and warnings.\n'
150
' -h, --help Show help message.\n'
161
' A code block follows.\n'
163
' bzr Demo something\n'
147
self.assertEqualDiff('''\
148
Purpose: A sample command.
152
-O ARG, --override-config=ARG
153
Override a configuration option value, e.g.
155
--usage Show usage message and options.
156
-q, --quiet Only display errors and warnings.
157
-v, --verbose Display more information.
158
-h, --help Show help message.
169
A code block follows.
165
175
helptext = cmd.get_help_text(plain=False)
166
self.assertEquals(helptext,
167
':Purpose: A sample command.\n'
171
' --usage Show usage message and options.\n'
172
' -v, --verbose Display more information.\n'
173
' -q, --quiet Only display errors and warnings.\n'
174
' -h, --help Show help message.\n'
185
' A code block follows.\n'
189
' bzr Demo something\n'
176
self.assertEqualDiff('''\
177
:Purpose: A sample command.
181
-O ARG, --override-config=ARG
182
Override a configuration option value, e.g.
184
--usage Show usage message and options.
185
-q, --quiet Only display errors and warnings.
186
-v, --verbose Display more information.
187
-h, --help Show help message.
198
A code block follows.
192
207
def test_concise_help_text(self):
193
208
"""Concise help text excludes the descriptive sections."""
205
220
helptext = cmd.get_help_text()
206
self.assertEqualDiff(
208
'Purpose: A sample command.\n'
212
' --usage Show usage message and options.\n'
213
' -v, --verbose Display more information.\n'
214
' -q, --quiet Only display errors and warnings.\n'
215
' -h, --help Show help message.\n'
221
self.assertEqualDiff('''\
222
Purpose: A sample command.
226
-O ARG, --override-config=ARG
227
Override a configuration option value, e.g.
229
--usage Show usage message and options.
230
-q, --quiet Only display errors and warnings.
231
-v, --verbose Display more information.
232
-h, --help Show help message.
225
244
helptext = cmd.get_help_text(verbose=False)
226
self.assertEquals(helptext,
227
'Purpose: A sample command.\n'
231
' --usage Show usage message and options.\n'
232
' -v, --verbose Display more information.\n'
233
' -q, --quiet Only display errors and warnings.\n'
234
' -h, --help Show help message.\n'
236
'See bzr help Demo for more details and examples.\n'
245
self.assertEqualDiff('''\
246
Purpose: A sample command.
250
-O ARG, --override-config=ARG
251
Override a configuration option value, e.g.
253
--usage Show usage message and options.
254
-q, --quiet Only display errors and warnings.
255
-v, --verbose Display more information.
256
-h, --help Show help message.
258
See bzr help Demo for more details and examples.
239
263
def test_help_custom_section_ordering(self):
240
264
"""Custom descriptive sections should remain in the order given."""
241
265
class cmd_Demo(commands.Command):
242
__doc__ = """A sample command.
247
Interesting stuff about formats.
255
Clever things to keep in mind.
272
Interesting stuff about formats.
280
Clever things to keep in mind.
258
283
helptext = cmd.get_help_text()
259
self.assertEqualDiff(
261
'Purpose: A sample command.\n'
265
' --usage Show usage message and options.\n'
266
' -v, --verbose Display more information.\n'
267
' -q, --quiet Only display errors and warnings.\n'
268
' -h, --help Show help message.\n'
274
' Interesting stuff about formats.\n'
282
' Clever things to keep in mind.\n'
284
self.assertEqualDiff('''\
285
Purpose: A sample command.
289
-O ARG, --override-config=ARG
290
Override a configuration option value, e.g.
292
--usage Show usage message and options.
293
-q, --quiet Only display errors and warnings.
294
-v, --verbose Display more information.
295
-h, --help Show help message.
301
Interesting stuff about formats.
309
Clever things to keep in mind.
285
314
def test_help_text_custom_usage(self):
286
315
"""Help text may contain a custom usage section."""
298
327
helptext = cmd.get_help_text()
299
self.assertEquals(helptext,
300
'Purpose: A sample command.\n'
302
' cmd Demo [opts] args\n'
308
' --usage Show usage message and options.\n'
309
' -v, --verbose Display more information.\n'
310
' -q, --quiet Only display errors and warnings.\n'
311
' -h, --help Show help message.\n'
314
' Blah blah blah.\n\n')
328
self.assertEqualDiff('''\
329
Purpose: A sample command.
337
-O ARG, --override-config=ARG
338
Override a configuration option value, e.g.
340
--usage Show usage message and options.
341
-q, --quiet Only display errors and warnings.
342
-v, --verbose Display more information.
343
-h, --help Show help message.
317
352
class ZzzTranslationsForDoc(ZzzTranslations):
343
378
__doc__ = """A sample command."""
344
379
_see_also = ['foo', 'bar']
345
380
self.assertCmdHelp('''\
346
zz{{:Purpose: zz{{A sample command.}}
347
}}zz{{:Usage: bzr WithSeeAlso
350
--usage zz{{Show usage message and options.}}
351
-v, --verbose zz{{Display more information.}}
352
-q, --quiet zz{{Only display errors and warnings.}}
353
-h, --help zz{{Show help message.}}
355
zz{{:See also: bar, foo}}
381
zz{{:Purpose: zz{{A sample command.}}
382
}}zz{{:Usage: bzr WithSeeAlso
385
-O ARG, --override-config=ARG
386
zz{{Override a configuration option value, e.g.
388
--usage zz{{Show usage message and options.}}
389
-q, --quiet zz{{Only display errors and warnings.}}
390
-v, --verbose zz{{Display more information.}}
391
-h, --help zz{{Show help message.}}
393
zz{{:See also: bar, foo}}
357
395
cmd_WithSeeAlso())
359
397
def test_get_help_text(self):
361
399
class cmd_Demo(commands.Command):
362
400
__doc__ = """A sample command."""
363
401
self.assertCmdHelp('''\
364
zz{{:Purpose: zz{{A sample command.}}
365
}}zz{{:Usage: bzr Demo
368
--usage zz{{Show usage message and options.}}
369
-v, --verbose zz{{Display more information.}}
370
-q, --quiet zz{{Only display errors and warnings.}}
371
-h, --help zz{{Show help message.}}
402
zz{{:Purpose: zz{{A sample command.}}
403
}}zz{{:Usage: bzr Demo
406
-O ARG, --override-config=ARG
407
zz{{Override a configuration option value, e.g.
409
--usage zz{{Show usage message and options.}}
410
-q, --quiet zz{{Only display errors and warnings.}}
411
-v, --verbose zz{{Display more information.}}
412
-h, --help zz{{Show help message.}}
376
417
def test_command_with_additional_see_also(self):
380
421
cmd = cmd_WithSeeAlso()
381
422
helptext = cmd.get_help_text(['gam'])
382
423
self.assertEndsWith(
384
' -v, --verbose zz{{Display more information.}}\n'
385
' -q, --quiet zz{{Only display errors and warnings.}}\n'
386
' -h, --help zz{{Show help message.}}\n'
388
'zz{{:See also: bar, foo, gam}}\n')
425
-q, --quiet zz{{Only display errors and warnings.}}
426
-v, --verbose zz{{Display more information.}}
427
-h, --help zz{{Show help message.}}
429
zz{{:See also: bar, foo, gam}}
390
432
def test_command_only_additional_see_also(self):
391
433
class cmd_WithSeeAlso(commands.Command):
393
435
cmd = cmd_WithSeeAlso()
394
436
helptext = cmd.get_help_text(['gam'])
395
437
self.assertEndsWith(
398
' --usage zz{{Show usage message and options.}}\n'
399
' -v, --verbose zz{{Display more information.}}\n'
400
' -q, --quiet zz{{Only display errors and warnings.}}\n'
401
' -h, --help zz{{Show help message.}}\n'
403
'zz{{:See also: gam}}\n')
440
-O ARG, --override-config=ARG
441
zz{{Override a configuration option value, e.g.
443
--usage zz{{Show usage message and options.}}
444
-q, --quiet zz{{Only display errors and warnings.}}
445
-v, --verbose zz{{Display more information.}}
446
-h, --help zz{{Show help message.}}
406
452
def test_help_custom_section_ordering(self):
423
469
Clever things to keep in mind.
425
471
self.assertCmdHelp('''\
426
zz{{:Purpose: zz{{A sample command.}}
427
}}zz{{:Usage: bzr Demo
430
--usage zz{{Show usage message and options.}}
431
-v, --verbose zz{{Display more information.}}
432
-q, --quiet zz{{Only display errors and warnings.}}
433
-h, --help zz{{Show help message.}}
436
zz{{zz{{Blah blah blah.}}
439
zz{{Interesting stuff about formats.}}
447
zz{{Clever things to keep in mind.}}
472
zz{{:Purpose: zz{{A sample command.}}
473
}}zz{{:Usage: bzr Demo
476
-O ARG, --override-config=ARG
477
zz{{Override a configuration option value, e.g.
479
--usage zz{{Show usage message and options.}}
480
-q, --quiet zz{{Only display errors and warnings.}}
481
-v, --verbose zz{{Display more information.}}
482
-h, --help zz{{Show help message.}}
485
zz{{zz{{Blah blah blah.}}
488
zz{{Interesting stuff about formats.}}
496
zz{{Clever things to keep in mind.}}
452
501
def test_help_text_custom_usage(self):
464
513
self.assertCmdHelp('''\
465
zz{{:Purpose: zz{{A sample command.}}
467
zz{{cmd Demo [opts] args}}
473
--usage zz{{Show usage message and options.}}
474
-v, --verbose zz{{Display more information.}}
475
-q, --quiet zz{{Only display errors and warnings.}}
476
-h, --help zz{{Show help message.}}
479
zz{{zz{{Blah blah blah.}}
514
zz{{:Purpose: zz{{A sample command.}}
516
zz{{cmd Demo [opts] args}}
522
-O ARG, --override-config=ARG
523
zz{{Override a configuration option value, e.g.
525
--usage zz{{Show usage message and options.}}
526
-q, --quiet zz{{Only display errors and warnings.}}
527
-v, --verbose zz{{Display more information.}}
528
-h, --help zz{{Show help message.}}
531
zz{{zz{{Blah blah blah.}}