-
Notifications
You must be signed in to change notification settings - Fork 93
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
Adds the description
and show_description
options to Choice
and InquirerControl
#330
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c4c076c
add description and show_description options
viniciusdc 1e8672a
show description by default, but only if set
pmeier fbd89ac
add docs
pmeier 699fa56
add test
pmeier b6de871
add show_description to checkbox
pmeier 5804140
add more docs
pmeier 4c5a9c8
trigger CI
pmeier 6ca24c8
Merge branch 'master' into 269_show_description
pmeier 9305d57
fix newline removal logic
pmeier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -222,3 +222,43 @@ def test_print_with_style(monkeypatch): | |
|
||
assert mock.method_calls[1][0] == "write" | ||
assert mock.method_calls[1][1][0] == "Hello World" | ||
|
||
|
||
def test_prompt_show_description(): | ||
ic = InquirerControl( | ||
["a", Choice("b", description="B")], | ||
show_selected=True, | ||
show_description=True, | ||
Comment on lines
+230
to
+231
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having both active asserts that they can coexist. |
||
) | ||
|
||
expected_tokens = [ | ||
("class:pointer", " » "), | ||
("[SetCursorPosition]", ""), | ||
("class:text", "○ "), | ||
("class:highlighted", "a"), | ||
("", "\n"), | ||
("class:text", " "), | ||
("class:text", "○ "), | ||
("class:text", "b"), | ||
("", "\n"), | ||
("class:text", " Answer: a"), | ||
] | ||
assert ic.pointed_at == 0 | ||
assert ic._get_choice_tokens() == expected_tokens | ||
|
||
ic.select_next() | ||
expected_tokens = [ | ||
("class:text", " "), | ||
("class:text", "○ "), | ||
("class:text", "a"), | ||
("", "\n"), | ||
("class:pointer", " » "), | ||
("[SetCursorPosition]", ""), | ||
("class:text", "○ "), | ||
("class:highlighted", "b"), | ||
("", "\n"), | ||
("class:text", " Answer: b"), | ||
("class:text", " Description: B"), | ||
] | ||
assert ic.pointed_at == 1 | ||
assert ic._get_choice_tokens() == expected_tokens |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viniciusdc I've changed this to
True
by default, because that is what the user expects when they set a description on aChoice
. Plus, since there are no descriptions yet, previous code is not affected by this.