Opened 14 years ago

Closed 14 years ago

#2231 defect closed duplicate (duplicate)

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

Reported by: David Reid Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:



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/ --help
Traceback (most recent call last):
  File "projects/", line 12, in ?
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/", line 177, in parseOptions
    self.__dispatch[optMangled](optMangled, arg)
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/", 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/", line 141, in opt_help
    print self.__str__()
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/", 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/", line 415, in getUsage
    chunks = docMakeChunks(cmdDicts, width)
  File "/private/Network/Servers/harris/Volumes/veedu/dreid/projects/Twisted/trunk/twisted/python/", line 517, in docMakeChunks
    short = "-%c" % (opt['short'],)
TypeError: %c requires int or char
zsh: exit 1     python projects/ --help

Attachments (1) (229 bytes) - added by David Reid 14 years ago.
bad subcommands example

Download all attachments as: .zip

Change History (3)

Changed 14 years ago by David Reid

Attachment: added

bad subcommands example

comment:1 Changed 14 years ago by David Reid

Resolution: duplicate
Status: newclosed

comment:2 Changed 9 years ago by <automation>

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