Skip to content
Myr

Some small fixes for problems

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent ded4bd5 · Browse files · 3 files+12 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+12 added−6 removed

  • other:+12 added−6 removed

3 files+12 added−6 removed

modified:click/_optparse.py+4 added-1 removed
7 unmodified lines
8# In case someone does depend on gettext being loaded into optparse we9# might have a problem but I don't think anyone will actually notice.10_gettext = sys.modules.get('gettext')11sys.modules['gettext'] = None12from optparse import IndentedHelpFormatter, OptionParser, Option12from optparse import IndentedHelpFormatter, OptionParser, Option, \13 SUPPRESS_HELP14if _gettext is not None:15 sys.modules['gettext'] = _gettext16else:17 del sys.modules['gettext']
68 unmodified lines
86 def error(self, msg):87 raise UsageError(msg, self.__ctx)888990# Re-exports91make_option = Option92SUPPRESS_HELP = SUPPRESS_HELP
modified:click/core.py+7 added-4 removed
352 unmodified lines
353 parser.disable_interspersed_args()354 return parser355356 def _format_extra_help(self, ctx):357 commands = self.list_commands()357 commands = self.list_commands(ctx)358 if not commands:359 return360361 longest = len(sorted(commands, key=len)[-1])362363 subcommand_info = []364 for subcommand in self.list_commands():364 for subcommand in self.list_commands(ctx):365 cmd = self.get_command(ctx, subcommand)366 # What is this, the tool lied about a command. Ignore it367 if cmd is None:368 continue369 help = cmd.short_help or ''370 subcommand_info.append(' %-*s %s' % (longest, subcommand, help))371372 return 'Commands:\n%s' % '\n'.join(subcommand_info)
29 unmodified lines
402 :class:`Command` object if it exists or returns `None`.403 """404 raise NotImplementedError()405403 def list_commands(self):406 def list_commands(self, ctx):407 """Returns a list of subcommand names in the order they should408 appear.409 """410 return []
34 unmodified lines
445446 def get_command(self, ctx, cmd_name):447 return self.commands.get(cmd_name)448446 def list_commands(self):449 def list_commands(self, ctx):450 return sorted(self.commands)451452453class Parameter(object):
399 unmodified lines
modified:docs/commands.rst+1 added-1 removed
174 unmodified lines
175 plugin_folder = os.path.join(os.path.dirname(__file__), 'commands')176177 class MyCLI(click.MultiCommand):178179 def list_commands(self):179 def list_commands(self, ctx):180 rv = []181 for filename in os.listdir(plugin_folder):182 if filename.endswith('.py'):183 rv.append(filename[:-3])
24 unmodified lines