Skip to content

Fixed two issues in cli #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 28, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions tmuxp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def prompt_yes_no(name, default=True):
return prompt_bool(name, default=default)


def prompt_choices(name, choices, default=None, resolve=ascii_lowercase,
no_choice=('none',)):
def prompt_choices(name, choices, default=None, no_choice=('none',)):
"""Return user input from command line from set of provided choices.

:param name: prompt text
Expand All @@ -123,7 +122,7 @@ def prompt_choices(name, choices, default=None, resolve=ascii_lowercase,
options = []

for choice in choices:
if isinstance(choice, basestring):
if type(choice) is str:
options.append(choice)
else:
options.append("%s [%s]" % (choice[1], choice[0]))
Expand All @@ -134,7 +133,7 @@ def prompt_choices(name, choices, default=None, resolve=ascii_lowercase,
rv = prompt(name + ' - (%s)' % ', '.join(options), default)
if not rv:
return default
rv = resolve(rv)
rv = rv.lower()
if rv in no_choice:
return None
if rv in _choices:
Expand Down Expand Up @@ -966,7 +965,9 @@ def main():
)

try:
if args.callback is command_load:
if not hasattr(args, 'callback'):
parser.print_help()
elif args.callback is command_load:
command_load(args)
elif args.callback is command_convert:
command_convert(args)
Expand All @@ -980,7 +981,5 @@ def main():
command_attach_session(args)
elif args.callback is command_kill_session:
command_kill_session(args)
else:
parser.print_help()
except KeyboardInterrupt:
pass