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
-q, --quiet Only display errors and warnings.
54
-v, --verbose Display more information.
55
-h, --help Show help message.
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.
61
61
def test_get_help_text(self):
63
63
class cmd_Demo(commands.Command):
64
64
__doc__ = """A sample command."""
65
65
self.assertCmdHelp('''\
66
Purpose: A sample command.
70
--usage Show usage message and options.
71
-q, --quiet Only display errors and warnings.
72
-v, --verbose Display more information.
73
-h, --help Show help message.
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.
78
78
helptext = cmd.get_help_text()
140
140
helptext = cmd.get_help_text()
141
self.assertEqualDiff('''\
142
Purpose: A sample command.
146
--usage Show usage message and options.
147
-q, --quiet Only display errors and warnings.
148
-v, --verbose Display more information.
149
-h, --help Show help message.
160
A code block follows.
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'
166
165
helptext = cmd.get_help_text(plain=False)
167
self.assertEqualDiff('''\
168
:Purpose: A sample command.
172
--usage Show usage message and options.
173
-q, --quiet Only display errors and warnings.
174
-v, --verbose Display more information.
175
-h, --help Show help message.
186
A code block follows.
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'
195
192
def test_concise_help_text(self):
196
193
"""Concise help text excludes the descriptive sections."""
208
205
helptext = cmd.get_help_text()
209
self.assertEqualDiff('''\
210
Purpose: A sample command.
214
--usage Show usage message and options.
215
-q, --quiet Only display errors and warnings.
216
-v, --verbose Display more information.
217
-h, --help Show help message.
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'
229
225
helptext = cmd.get_help_text(verbose=False)
230
self.assertEqualDiff('''\
231
Purpose: A sample command.
235
--usage Show usage message and options.
236
-q, --quiet Only display errors and warnings.
237
-v, --verbose Display more information.
238
-h, --help Show help message.
240
See bzr help Demo for more details and examples.
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
239
def test_help_custom_section_ordering(self):
246
240
"""Custom descriptive sections should remain in the order given."""
247
241
class cmd_Demo(commands.Command):
254
Interesting stuff about formats.
262
Clever things to keep in mind.
242
__doc__ = """A sample command.
247
Interesting stuff about formats.
255
Clever things to keep in mind.
265
258
helptext = cmd.get_help_text()
266
self.assertEqualDiff('''\
267
Purpose: A sample command.
271
--usage Show usage message and options.
272
-q, --quiet Only display errors and warnings.
273
-v, --verbose Display more information.
274
-h, --help Show help message.
280
Interesting stuff about formats.
288
Clever things to keep in mind.
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'
293
285
def test_help_text_custom_usage(self):
294
286
"""Help text may contain a custom usage section."""
306
298
helptext = cmd.get_help_text()
307
self.assertEqualDiff('''\
308
Purpose: A sample command.
316
--usage Show usage message and options.
317
-q, --quiet Only display errors and warnings.
318
-v, --verbose Display more information.
319
-h, --help Show help message.
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
317
class ZzzTranslationsForDoc(ZzzTranslations):
354
343
__doc__ = """A sample command."""
355
344
_see_also = ['foo', 'bar']
356
345
self.assertCmdHelp('''\
357
zz{{:Purpose: zz{{A sample command.}}
358
}}zz{{:Usage: bzr WithSeeAlso
361
--usage zz{{Show usage message and options.}}
362
-q, --quiet zz{{Only display errors and warnings.}}
363
-v, --verbose zz{{Display more information.}}
364
-h, --help zz{{Show help message.}}
366
zz{{:See also: bar, foo}}
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}}
368
357
cmd_WithSeeAlso())
370
359
def test_get_help_text(self):
372
361
class cmd_Demo(commands.Command):
373
362
__doc__ = """A sample command."""
374
363
self.assertCmdHelp('''\
375
zz{{:Purpose: zz{{A sample command.}}
376
}}zz{{:Usage: bzr Demo
379
--usage zz{{Show usage message and options.}}
380
-q, --quiet zz{{Only display errors and warnings.}}
381
-v, --verbose zz{{Display more information.}}
382
-h, --help zz{{Show help message.}}
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.}}
387
376
def test_command_with_additional_see_also(self):
391
380
cmd = cmd_WithSeeAlso()
392
381
helptext = cmd.get_help_text(['gam'])
393
382
self.assertEndsWith(
395
-q, --quiet zz{{Only display errors and warnings.}}
396
-v, --verbose zz{{Display more information.}}
397
-h, --help zz{{Show help message.}}
399
zz{{:See also: bar, foo, gam}}
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')
402
390
def test_command_only_additional_see_also(self):
403
391
class cmd_WithSeeAlso(commands.Command):
405
393
cmd = cmd_WithSeeAlso()
406
394
helptext = cmd.get_help_text(['gam'])
407
395
self.assertEndsWith(
410
--usage zz{{Show usage message and options.}}
411
-q, --quiet zz{{Only display errors and warnings.}}
412
-v, --verbose zz{{Display more information.}}
413
-h, --help zz{{Show help message.}}
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')
419
406
def test_help_custom_section_ordering(self):
436
423
Clever things to keep in mind.
438
425
self.assertCmdHelp('''\
439
zz{{:Purpose: zz{{A sample command.}}
440
}}zz{{:Usage: bzr Demo
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.}}
449
zz{{zz{{Blah blah blah.}}
452
zz{{Interesting stuff about formats.}}
460
zz{{Clever things to keep in mind.}}
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.}}
465
452
def test_help_text_custom_usage(self):
477
464
self.assertCmdHelp('''\
478
zz{{:Purpose: zz{{A sample command.}}
480
zz{{cmd Demo [opts] args}}
486
--usage zz{{Show usage message and options.}}
487
-q, --quiet zz{{Only display errors and warnings.}}
488
-v, --verbose zz{{Display more information.}}
489
-h, --help zz{{Show help message.}}
492
zz{{zz{{Blah blah blah.}}
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.}}