~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-05-03 07:56:14 UTC
  • Revision ID: mbp@sourcefrog.net-20050503075614-dcf02e7266911b23
- nicer formatting of help for options

Show diffs side-by-side

added added

removed removed

Lines of Context:
741
741
    if rest:
742
742
        print rest
743
743
 
744
 
    if cmdclass.takes_options:
745
 
        print
746
 
        print 'options:'
747
 
        for on in cmdclass.takes_options:
748
 
            print '    --%s' % on
 
744
    help_on_option(cmdclass.takes_options)
 
745
 
 
746
 
 
747
def help_on_option(options):
 
748
    if not options:
 
749
        return
 
750
    
 
751
    print
 
752
    print 'options:'
 
753
    for on in options:
 
754
        l = '    --' + on
 
755
        for shortname, longname in SHORT_OPTIONS.items():
 
756
            if longname == on:
 
757
                l += ', -' + shortname
 
758
                break
 
759
        print l
749
760
 
750
761
 
751
762
def help_commands():
764
775
        help = inspect.getdoc(cmdclass)
765
776
        if help:
766
777
            print "    " + help.split('\n', 1)[0]
767
 
 
 
778
            
768
779
 
769
780
######################################################################
770
781
# main routine