canonical / craft-cli

https://canonical-craft-cli.readthedocs-hosted.com/en/latest/
GNU Lesser General Public License v3.0
9 stars 15 forks source link

emitter: add "streaming brief" feature #166

Closed tigarmo closed 1 year ago

tigarmo commented 1 year ago

This commit adds a new feature to the Emitter, tentatively called "streaming brief". It is initially disabled, and can be enabled in the Emitter's init() call.

Once enabled, the feature will leverage the "multi-action" nature of progress() calls to "stream", in a single line, info-level log messages and text written to the open_stream()'s pipe. For example, the following sequence of calls in BRIEF mode:

emit.progress("Starting stage 1", permanent=False) ...
log.info("Doing first step")
...
log.info("Doing second step")
...
emit.progress("Finished stage 1", permanent=True)

... will cause the two 'info' messages to "stream" on the terminal, prefixed by "Starting stage 1 ::" to indicate that they are related to that progress message. All these three messages are ephemeral which means that in the end only the final progress() call will be visible on the terminal.

Fixes #165

codecov[bot] commented 1 year ago

Codecov Report

Merging #166 (3ad948e) into main (659cac9) will increase coverage by 0.13%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #166      +/-   ##
==========================================
+ Coverage   94.40%   94.54%   +0.13%     
==========================================
  Files           7        7              
  Lines        1019     1044      +25     
  Branches      187      192       +5     
==========================================
+ Hits          962      987      +25     
  Misses         53       53              
  Partials        4        4              
Files Changed Coverage Δ
craft_cli/messages.py 100.00% <100.00%> (ø)
craft_cli/printer.py 100.00% <100.00%> (ø)