119
119
raise CommandError("Unknown shelf subcommand '%s'" % cmd_name)
122
lines = ["%s\n\nSubcommands:" % self.__doc__]
122
text = ["%s\n\nSubcommands:\n" % self.__doc__]
126
124
for cmd_class in self.subcommands:
127
usage = command_usage(cmd_class())
128
usage = usage.replace('bzr shelf-', '')
129
sub_help.append((usage, cmd_class.__doc__))
130
maxlen = max(maxlen, len(usage))
132
for usage, doc in sub_help:
133
lines.append(" %-*s %s" % (maxlen, usage, doc))
135
return '\n'.join(lines)
125
text.extend(self.sub_help(cmd_class) + ['\n'])
129
def sub_help(self, cmd_class):
131
cmd_obj = cmd_class()
134
usage = command_usage(cmd_obj)
135
usage = usage.replace('bzr shelf-', '')
136
text.append('%s%s\n' % (indent, usage))
138
text.append('%s%s\n' % (2 * indent, cmd_class.__doc__))
140
# Somewhat copied from bzrlib.help.help_on_command_options
142
for option_name, option in sorted(cmd_obj.options().items()):
143
if option_name == 'help':
145
option_help.append('%s--%s' % (3 * indent, option_name))
146
if option.type is not None:
147
option_help.append(' %s' % option.argname.upper())
148
if option.short_name():
149
option_help.append(', -%s' % option.short_name())
150
option_help.append('%s%s\n' % (2 * indent, option.help))
152
if len(option_help) > 0:
153
text.append('%soptions:\n' % (2 * indent))
154
text.extend(option_help)
138
159
class cmd_unshelve(bzrlib.commands.Command):