Opened 8 years ago

Closed 8 years ago

#2231 defect closed duplicate (duplicate)

t.p.usage documents multicharacter shortcuts for subcommands but does not support them.

Reported by: dreid Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author: Launchpad Bug:

Description

From http://twistedmatrix.com/documents/current/api/twisted.python.usage.Options.html:

subCommands is a list of 4-tuples of (command name, command shortcut, parser class, documentation). If the first non-option argument found is one of the given command names, an instance of the given parser class is instantiated and given the remainder of the arguments to parse and self.opts[command] is set to the command name. For example:

| subCommands = [ | ['inquisition', 'inquest', InquisitionOptions, 'Perform an inquisition'], | ['holyquest', 'quest', HolyQuestOptions, 'Embark upon a holy quest'] | ]

However actually using a multicharacter command shortcut causes a typeerror to be raised when issuing --help.

dreid:~> python projects/bs.py --help
Traceback (most recent call last):
  File "projects/bs.py", line 12, in ?
    Options().parseOptions()
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/usage.py", line 177, in parseOptions
    self.__dispatch[optMangled](optMangled, arg)
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/usage.py", line 337, in <lambda>
    fn = lambda name, value=None, m=method: m()
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/usage.py", line 141, in opt_help
    print self.__str__()
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/usage.py", line 373, in __str__
    return self.getSynopsis() + '\n' + self.getUsage(width=None)
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/usage.py", line 415, in getUsage
    chunks = docMakeChunks(cmdDicts, width)
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/usage.py", line 517, in docMakeChunks
    short = "-%c" % (opt['short'],)
TypeError: %c requires int or char
zsh: exit 1     python projects/bs.py --help

Attachments (1)

bs.py (229 bytes) - added by dreid 8 years ago.
bad subcommands example

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by dreid

bad subcommands example

comment:1 Changed 8 years ago by dreid

  • Resolution set to duplicate
  • Status changed from new to closed

comment:2 Changed 3 years ago by <automation>

  • Owner glyph deleted
Note: See TracTickets for help on using tickets.