Skip to content

Commit c2e4306

Browse files
committed
fixes
1 parent 5bbfc9b commit c2e4306

File tree

9 files changed

+31
-36
lines changed

9 files changed

+31
-36
lines changed

PyInquirer/prompt.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def prompt(questions, answers=None, **kwargs):
1818
true_color = kwargs.pop('true_color', False)
1919
refresh_interval = kwargs.pop('refresh_interval', 0)
2020
eventloop = kwargs.pop('eventloop', None)
21+
kbi_msg = kwargs.pop('keyboard_interrupt_msg', 'Cancelled by user')
22+
2123

2224
for question in questions:
2325
# import the question
@@ -82,7 +84,7 @@ def prompt(questions, answers=None, **kwargs):
8284
raise ValueError('No question type \'%s\'' % type)
8385
except KeyboardInterrupt:
8486
print('')
85-
print('Cancelled by user')
87+
print(kbi_msg)
8688
print('')
8789
return {}
8890
return answers

PyInquirer/prompts/checkbox.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ def question(message, **kwargs):
127127
style = kwargs.pop('style', default_style)
128128

129129
ic = InquirerControl(choices)
130+
qmark = kwargs.pop('qmark', '?')
130131

131132
def get_prompt_tokens(cli):
132133
tokens = []
133134

134-
tokens.append((Token.QuestionMark, '?'))
135+
tokens.append((Token.QuestionMark, qmark))
135136
tokens.append((Token.Question, ' %s ' % message))
136137
if ic.answered:
137138
nbr_selected = len(ic.selected_options)

PyInquirer/prompts/confirm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ def question(message, **kwargs):
3030
}))
3131
status = {'answer': None}
3232

33+
qmark = kwargs.pop('qmark', '?')
34+
3335
def get_prompt_tokens(cli):
3436
tokens = []
3537

36-
tokens.append((Token.QuestionMark, '?'))
38+
tokens.append((Token.QuestionMark, qmark))
3739
tokens.append((Token.Question, ' %s ' % message))
3840
if isinstance(status['answer'], bool):
3941
tokens.append((Token.Answer, ' Yes' if status['answer'] else ' No'))

PyInquirer/prompts/expand.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def question(message, **kwargs):
120120

121121
choices = kwargs.pop('choices', None)
122122
default = kwargs.pop('default', None)
123-
123+
qmark = kwargs.pop('qmark', '?')
124124
# TODO style defaults on detail level
125125
style = kwargs.pop('style', default_style)
126126

@@ -130,7 +130,7 @@ def get_prompt_tokens(cli):
130130
tokens = []
131131
T = Token
132132

133-
tokens.append((T.QuestionMark, '?'))
133+
tokens.append((T.QuestionMark, qmark))
134134
tokens.append((T.Question, ' %s ' % message))
135135
if not ic.answered:
136136
tokens.append((T.Instruction, ' (%s)' % ''.join(

PyInquirer/prompts/input.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ def validate(self, document):
3333

3434
# TODO style defaults on detail level
3535
kwargs['style'] = kwargs.pop('style', default_style)
36+
qmark = kwargs.pop('qmark', '?')
37+
3638

3739
def _get_prompt_tokens(cli):
3840
return [
39-
(Token.QuestionMark, '?'),
41+
(Token.QuestionMark, qmark),
4042
(Token.Question, ' %s ' % message)
4143
]
4244

PyInquirer/prompts/list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def question(message, **kwargs):
110110

111111
choices = kwargs.pop('choices', None)
112112
default = kwargs.pop('default', 0) # TODO
113-
113+
qmark = kwargs.pop('qmark', '?')
114114
# TODO style defaults on detail level
115115
style = kwargs.pop('style', default_style)
116116

@@ -119,7 +119,7 @@ def question(message, **kwargs):
119119
def get_prompt_tokens(cli):
120120
tokens = []
121121

122-
tokens.append((Token.QuestionMark, '?'))
122+
tokens.append((Token.QuestionMark, qmark))
123123
tokens.append((Token.Question, ' %s ' % message))
124124
if ic.answered:
125125
tokens.append((Token.Answer, ' ' + ic.get_selection()[0]))

PyInquirer/prompts/rawlist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def question(message, **kwargs):
103103
#if 'default' in kwargs:
104104
# raise ValueError('rawlist does not implement \'default\' '
105105
# 'use \'checked\':True\' in choice!')
106-
106+
qmark = kwargs.pop('qmark', '?')
107107
choices = kwargs.pop('choices', None)
108108
if len(choices) > 9:
109109
raise ValueError('rawlist supports only a maximum of 9 choices!')
@@ -117,7 +117,7 @@ def get_prompt_tokens(cli):
117117
tokens = []
118118
T = Token
119119

120-
tokens.append((T.QuestionMark, '?'))
120+
tokens.append((T.QuestionMark, qmark))
121121
tokens.append((T.Question, ' %s ' % message))
122122
if ic.answered:
123123
tokens.append((T.Answer, ' %s' % ic.get_selected_value()))

README.md

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# PythonInquirer?
1+
# PythonInquirer
22

3-
A collection of common interactive command line user interfaces. It is originally called whaaaaaat created by, but due to the author not active, outdated, bad naming and in need of fixes, I decided to rename and apply some fixes on it. I'll also carry out the author's TODO.
3+
A collection of common interactive command line user interfaces. It is originally called [whaaaaaat](https://github.com/finklabs/whaaaaat) created by **finklabs**, but due to bad naming and in need of fixes, I decided to rename and apply some necessary fixes on it. I'll also carry out the author's TODO.
44

55
## Table of Contents
66

@@ -13,7 +13,7 @@ A collection of common interactive command line user interfaces. It is originall
1313
6. [User Interfaces and Styles](#styles)
1414
2. [Windows Platform](#windows)
1515
3. [Support](#support)
16-
4. [Contributing](#contributing)
16+
4. [Contribution](#contribution)
1717
5. [Acknowledgments](#acknowledgements)
1818
6. [License](#license)
1919

@@ -31,8 +31,6 @@ A collection of common interactive command line user interfaces. It is originall
3131

3232
**Note:** **`PyInquirer`** provides the user interface and the inquiry session flow.
3333
>
34-
If you're searching for a scaffolding utility, then check out [banana](https://github.com/finklabs/banana), the whaaaaat sister utility.
35-
3634
3735
## Documentation
3836
<a name="documentation"></a>
@@ -104,7 +102,7 @@ Take `type`, `name`, `message`, `choices`[, `default`, `filter`] properties. (No
104102
default must be the choice `index` in the array or a choice `value`)
105103

106104
![List prompt](https://raw.githubusercontent.com/citguru/PyInquirer/develop/docs/images/input-prompt.png)
107-
105+
s
108106
---
109107

110108
#### Raw List - `{type: 'rawlist'}`
@@ -214,26 +212,15 @@ Issue on Github TODO link
214212

215213
For many issues like for example common Python programming issues stackoverflow might be a good place to search for an answer. TODO link
216214

217-
Visit the citguru slack channel for announcements and news. TODO link
218-
219-
220-
## Contributing
221-
<a name="contributing"></a>
222-
223-
Unit test Unit test are written using pytest. Please add a unit test for every new feature or bug fix.
224-
225-
Documentation Add documentation for every API change. Feel free to send typo fixes and better docs!
226-
227-
We're looking to offer good support for multiple prompts and environments. If you want to help, we'd like to keep a list of testers for each terminal/OS so we can contact you and get feedback before release. Let us know if you want to be added to the list.
228-
229-
230-
## Acknowledgments
231-
<a name="acknowledgements"></a>
232-
233-
Many thanks to our friends at Inquirer.js. We think they did a great job developing the tooling to support the nodejs technology.
215+
<a name="contribution"></a>
216+
## Contribution
234217

218+
Yes, you can contribute to this.
235219

236220
## License
237221
<a name="license"></a>
238222

239-
Copyright (c) 2016-2017 Mark Fink (twitter: @markfink) Licensed under the MIT license.
223+
Copyright (c) 2016-2017
224+
Mark Fink (twitter: @markfink)
225+
Oyetoke Toby ((twitter: @oyetokeT))
226+
Licensed under the MIT license.

examples/checkbox.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
questions = [
2424
{
2525
'type': 'checkbox',
26+
'qmark': '[?]',
2627
'message': 'Select toppings',
2728
'name': 'toppings',
28-
'choices': [
29+
'choices': [
2930
Separator('= The Meats ='),
3031
{
3132
'name': 'Ham'
@@ -76,4 +77,4 @@
7677

7778
answers = prompt(questions, style=style)
7879
pprint(answers)
79-
80+

0 commit comments

Comments
 (0)