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

CraftError messages with new lines render inconsistently #269

Open mr-cal opened 2 months ago

mr-cal commented 2 months ago

Bug Description

If the message field in a CraftError contains a new line, craft-cli appears to append whitespace, which causes the appearance of a new line between the message and resolution sections.

Note that I cannot use the details field because details isn't visible at the default brief verbosity level.

To Reproduce

diff --git a/examples.py b/examples.py
index c842a1a..c7fe76e 100755
--- a/examples.py
+++ b/examples.py
 def example_10():
@@ -513,6 +516,15 @@ def example_30():
         time.sleep(0.001)

+def example_31():
+    """Show an error."""
+    path = "/dev/null"
+    raise CraftError(
+        message="Remote build does not support building multiple snaps on the same architecture:\n  - Building on 'amd64' will create snaps for 'amd64' and 'riscv64'.",
+        resolution="this is the resolution",
+    )
+
+
 # -- end of test cases

 if len(sys.argv) < 2:

part yaml

No response

Relevant log output

See the attached pictures. The same photo is highlighted to show what appears to be extraneous whitespace.

Screenshot_20240827_164350

Screenshot_20240827_164359

syncronize-issues-to-jira[bot] commented 2 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3312.

This message was autogenerated

lengau commented 2 months ago

Huh... I'd always presumed that was intentional, but yeah that makes sense. I'm pretty sure that #210 indirectly fixes this (since it doesn't use spaces to fill the line).