Skip to content
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

printer: enhance ephemeral message handover after stop() or pause() #126

Merged
merged 2 commits into from
Oct 17, 2022

Conversation

flotter
Copy link
Contributor

@flotter flotter commented Oct 7, 2022

It is a very common pattern for craft tools to start the session
directly on a host machine, but launch another craft instance to
do the actual work inside LXD or Multipass.

In order for a seamless CLI experience (which looks identical
between a 'destructive build' on the host, LXD or Multipass),
we need support for progress messages (ephemeral=True) to seamlessly
cross the boundaries between the host and the container instance of
of the craft tool.

Please see examples.py #26 for an example.

Add support for _Printer to respect ephemeral messages when
stopping. On printer stop(), these messages are no longer terminated
with a newline, but instead the printer will clear and reset the
cursor to the start of the line.

This behaviour change will allow subsequent terminal writes by a
different process the ability to reuse a terminal line previously
used as ephemeral output.

@flotter flotter force-pushed the enhance-transcient-emit-pause branch from 27cdff6 to 652447a Compare October 10, 2022 15:03
@flotter flotter changed the title printer: enhance ephemeral message handover after stop() printer: enhance ephemeral message handover after stop() or pause() Oct 10, 2022
@flotter flotter force-pushed the enhance-transcient-emit-pause branch from 652447a to 1e787dc Compare October 10, 2022 15:14
It is a very common pattern for craft tools to start the session
directly on a host machine, but launch another craft instance to
do the actual work inside LXD or Multipass.

In order for a seamless CLI experience (which looks identical
between a 'destructive build' on the host, LXD or Multipass),
we need support for progress messages (ephemeral=True) to seamlessly
cross the boundaries between the host and the container instance of
of the craft tool.

Please see examples.py canonical#26 for an example.

Add support for _Printer to respect ephemeral messages when
stopping. On printer stop(), these messages are no longer terminated
with a newline, but instead the printer will clear and reset the
cursor to the start of the line.

This behaviour change will allow subsequent terminal writes by a
different process the ability to reuse a terminal line previously
used as ephemeral output.
@flotter flotter force-pushed the enhance-transcient-emit-pause branch from 1e787dc to 9f9df27 Compare October 10, 2022 15:20
Copy link
Contributor

@facundobatista facundobatista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for this! Annotated a couple of details for improvement. Thanks again!

craft_cli/messages.py Show resolved Hide resolved
tests/unit/test_messages_integration.py Show resolved Hide resolved
tests/unit/test_messages_integration.py Show resolved Hide resolved
Copy link
Contributor

@facundobatista facundobatista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful, thanks for this work!!!

tests/unit/test_messages_integration.py Show resolved Hide resolved
@facundobatista
Copy link
Contributor

@flotter note that some tests are failing...

@flotter flotter force-pushed the enhance-transcient-emit-pause branch from 0f5da8d to 5397749 Compare October 17, 2022 10:15
@flotter flotter force-pushed the enhance-transcient-emit-pause branch from 5397749 to 146b966 Compare October 17, 2022 10:29
@facundobatista facundobatista merged commit 2cbced2 into canonical:main Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants