-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #25: Authentication cli assistant
- Loading branch information
Showing
3 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import click | ||
|
||
|
||
def choices_prompt(text, choices, default_choice): | ||
choices_descriptions = [' [{}]{}'.format(choice[0].upper() if default_choice == choice[0] else choice[0], | ||
choice[1:]) | ||
for choice in choices] | ||
choices_letters = [choice[0].upper() if default_choice == choice[0] else choice[0] for choice in choices] | ||
choice = click.prompt( | ||
'{}\n\n'.format(text) + | ||
'\n'.join(choices_descriptions) + | ||
'\nEnter a choice [{}]'.format('/'.join(choices_letters)), | ||
default=default_choice, show_default=False | ||
) | ||
if not next(iter(filter(lambda x: x == choice.lower(), map(lambda x: x.lower(), choices_letters))), None): | ||
return default_choice | ||
return choice.lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters