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
--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.
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
-v, --verbose Display more information.
72
-q, --quiet Only display errors and warnings.
73
-h, --help Show help message.
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.
78
78
helptext = cmd.get_help_text()
140
140
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'
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.
165
166
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'
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.
192
195
def test_concise_help_text(self):
193
196
"""Concise help text excludes the descriptive sections."""
205
208
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'
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.
225
229
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'
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.
239
245
def test_help_custom_section_ordering(self):
240
246
"""Custom descriptive sections should remain in the order given."""
241
247
class cmd_Demo(commands.Command):
242
__doc__ = """A sample command.
247
Interesting stuff about formats.
255
Clever things to keep in mind.
254
Interesting stuff about formats.
262
Clever things to keep in mind.
258
265
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'
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.
285
293
def test_help_text_custom_usage(self):
286
294
"""Help text may contain a custom usage section."""
298
306
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')
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.
317
328
class ZzzTranslationsForDoc(ZzzTranslations):
343
354
__doc__ = """A sample command."""
344
355
_see_also = ['foo', 'bar']
345
356
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}}
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}}
357
368
cmd_WithSeeAlso())
359
370
def test_get_help_text(self):
361
372
class cmd_Demo(commands.Command):
362
373
__doc__ = """A sample command."""
363
374
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.}}
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.}}
376
387
def test_command_with_additional_see_also(self):
380
391
cmd = cmd_WithSeeAlso()
381
392
helptext = cmd.get_help_text(['gam'])
382
393
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')
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}}
390
402
def test_command_only_additional_see_also(self):
391
403
class cmd_WithSeeAlso(commands.Command):
393
405
cmd = cmd_WithSeeAlso()
394
406
helptext = cmd.get_help_text(['gam'])
395
407
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')
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.}}
406
419
def test_help_custom_section_ordering(self):
423
436
Clever things to keep in mind.
425
438
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.}}
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.}}
452
465
def test_help_text_custom_usage(self):
464
477
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.}}
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.}}