Skip to content

Commit

Permalink
List registered commands in help text
Browse files Browse the repository at this point in the history
Fixes pypa#34
Closes pypa#54
  • Loading branch information
sigmavirus24 committed Dec 11, 2014
1 parent 6846fc4 commit 2c0d6aa
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions twine/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@
import twine


def _registered_commands(group='twine.registered_commands'):
return list(pkg_resources.iter_entry_points(group=group))


def dispatch(argv):
registered_commands = _registered_commands()
parser = argparse.ArgumentParser(prog="twine")
parser.add_argument(
"--version",
action="version",
version="%(prog)s version {0}".format(twine.__version__),
)
parser.add_argument("command")
parser.add_argument(
"command",
choices=[c.name for c in registered_commands],
)
parser.add_argument(
"args",
help=argparse.SUPPRESS,
Expand All @@ -36,9 +44,8 @@ def dispatch(argv):

args = parser.parse_args(argv)

group = 'twine.registered_commands'
command = args.command
for registered_command in pkg_resources.iter_entry_points(group):
for registered_command in registered_commands:
if registered_command.name == command:
break
else:
Expand Down

0 comments on commit 2c0d6aa

Please sign in to comment.