-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(status): allow to nest statuses and prompt inside
- Loading branch information
1 parent
a996fa0
commit f62625e
Showing
10 changed files
with
168 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from tests_e2e.__specs.utils.hexagon_spec import as_a_user | ||
|
||
|
||
def test_status_is_shown_correctly(): | ||
""" | ||
We are not actually testing the display of the spinner, | ||
rich hides it when not running in a TTY. | ||
But we are testing that status nesting and prompting works correctly. | ||
""" | ||
( | ||
as_a_user(__file__) | ||
.run_hexagon(["status"], os_env_vars={"HEXAGON_THEME": "no_border"}) | ||
.then_output_should_be( | ||
["Test", "", "some info 1", "some info 2", "update?"], | ||
ignore_blank_lines=False, | ||
) | ||
.input("y") | ||
.then_output_should_be( | ||
[ | ||
"update? Yes", | ||
"about to show nested status", | ||
"inside nested status", | ||
"prompting...", | ||
"enter something", | ||
] | ||
) | ||
.input("asdf") | ||
.then_output_should_be( | ||
[ | ||
"entered", | ||
"back to main status", | ||
"showing a new status...", | ||
"inside new status", | ||
], | ||
) | ||
.exit(status=0) | ||
) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cli: | ||
name: Test | ||
command: hexagon-test | ||
custom_tools_dir: . | ||
|
||
tools: | ||
- name: status | ||
action: status | ||
type: shell | ||
alias: s | ||
long_name: Show different statuses | ||
|
||
envs: [] |
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,24 @@ | ||
import time | ||
|
||
from hexagon.support.printer import log | ||
from hexagon.support.prompt import prompt | ||
|
||
|
||
def main(*_): | ||
with log.status("first status shown..."): | ||
log.info("some info 1") | ||
log.info("some info 2") | ||
time.sleep(1) | ||
if not prompt.confirm("update?", default=True): | ||
return | ||
log.info("about to show nested status") | ||
with log.status("nested status..."): | ||
log.info("inside nested status") | ||
log.info("prompting...") | ||
text = prompt.text(message="enter something") | ||
log.info(f"entered {text}") | ||
log.info("back to main status") | ||
|
||
log.info("showing a new status...") | ||
with log.status("new status..."): | ||
log.info("inside new status") |