Feature left right center alignment #8
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ignyte.link/cliasi!8
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/left_right_middle_alignment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add alignment possibilities left, right and center
Pull request overview
This pull request adds left, right, and center text alignment capabilities to the cliasi CLI library. The feature allows messages to be positioned at different locations on the terminal line, with intelligent fallback behavior when content doesn't fit.
Changes:
messageparameter tomessage_leftacross all public methods and addedmessage_centerandmessage_rightparametersCursorPosenum for controlling input cursor position in interactive promptsReviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 16 comments.
Show a summary per file
__printand__format_progressbar_to_screen_widthmethods; updated all public method signaturesCursorPosenum and modified download animation symbolCursorPosenum in public APImessage_leftparameter name💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -38,9 +39,10 @@ Cliasi instance-----------------The word "weather" should be "whether" in this context. "Weather" refers to atmospheric conditions, while "whether" introduces alternatives.
@ -43,7 +44,7 @@ Here is a quick example to get you started:# Finish downloadThe parameter name in the code example doesn't match the actual API. The code shows 'right="100%"' but the actual parameter name is 'message_right' based on the API changes in this PR. This should be 'message_right="100%"'.
@ -204,3 +213,55 @@ You can ask for user input, including passwords.class="asciinema_demo-dark"The note states "all aligned will be printed one after the other except for 'right' aligned text". However, this description is incomplete and potentially misleading. The actual behavior is more nuanced: right-aligned text attempts to print on the last line if there's space, otherwise it also wraps. The documentation should be clearer about this fallback behavior.
The phrase "If the left message goes to far" should be "If the left message goes too far" (two 'o's in "too").
@ -23,7 +23,7 @@ cli.newline()cli.set_prefix("LINEBREAKS")cli.message("LINEBREAK TEST\nSUCCESSFUL")The space was added after the exclamation mark, but there's no comment explaining why this is needed. If this is a test change related to alignment, it should be noted. If it's fixing an existing issue (like missing spaces causing readability issues), it should be mentioned.
@ -36,7 +37,8 @@ try:rows = int(os.environ.get("LINES", 24))The comment on line 40 is grammatically incorrect. It should read "to avoid printing progress to the maximum" or "to avoid printing to the terminal edge" rather than "to avoid printing progress to the max."
Subtracting 1 from the terminal size globally affects all parts of the application, not just progress bars. This is a behavioral change that could affect existing layouts and should be carefully considered. The comment suggests this is to avoid printing to the maximum width, but this should be handled specifically in the contexts where it's needed rather than globally reducing the available width for all operations.
The word "seperator" is misspelled throughout the codebase. It should be spelled "separator" (with an 'a', not an 'e').
@ -136,48 +145,240 @@ class Cliasi:self,The variable name "seperating_space" is misspelled. It should be "separating_space" (with an 'a', not an 'e'). This misspelling appears multiple times in the code.
@ -173,0 +266,4 @@center_end = len(lines[-1])right_end = len(lines[-1])# CursorPos alignment not possible because message_right is multiline# we are done test_right_multiline_too_longThe API design for using boolean flags (True/False) to control alignment is confusing. When message_left is set to False or a bool flag is passed, it's not clear from the API what the expected behavior is. For example, in the code
cli.warn(False, message_center="This is a centered message."), passing False as the first argument is not intuitive. Consider using Optional[str] with None as the default, or using dedicated alignment parameters likealign="center"for clearer intent.Throughout the file, the phrase "If messages dont fit" is missing an apostrophe. It should be "If messages don't fit". This error appears in approximately 30 docstrings throughout the file.
This is a breaking change. The parameter name has been changed from "message" to "message_left" in all public methods. While the functionality is an enhancement, this will break existing code that uses keyword arguments. Consider deprecating the old parameter name first or documenting this as a breaking change in release notes.
@ -571,1 +1020,4 @@Message to display in the center of the bar or bool flag to disable:param message_right:Message to display on the right side of the bar or bool flag to disable:param symbol: Symbol to get symbol lengthThe variable name "seperating_space" is misspelled. It should be "separating_space" (with an 'a', not an 'e').
The progressbar methods have changed the default value of message_center from False to True. This changes the default behavior for existing code - messages that were previously left-aligned will now be centered. This is a breaking change in behavior that should be carefully considered and documented.
@ -85,13 +85,22 @@ ANIMATIONS_MAIN: list[dict[str, int | list[str]]] = [The CursorPos enum uses integer values (0, 1, 2) but these are not used consistently in the code. At line 833, the code checks
cursor_position != CursorPos.RIGHTand then at line 836 checkscursor_position == CursorPos.LEFT. However, the enum could be better designed as a StrEnum or the logic could use the enum's name property for clearer intent. The current implementation works but could be more explicit.@ -87,3 +87,3 @@"default": ANIMATIONS_SYMBOLS,"download": [["🢓", "↧", "⭣", "⯯", "⤓", "⩡", "_", "_"]],"download": [["°", "↧", "⭣", "⯯", "⤓", "⩡", "_", "_"]],}The download animation symbol has been changed from "🢓" to "°". This appears to be an unrelated change that should not be part of an alignment feature PR. If this change is intentional, it should be explained in the PR description or done in a separate commit. The degree symbol "°" doesn't seem semantically appropriate for representing a download.