Feature left right center alignment #8

Merged
Qrashi merged 13 commits from feature/left_right_middle_alignment into release/0.4.0 2026-01-15 01:22:30 +01:00
Qrashi commented 2026-01-15 00:36:27 +01:00 (Migrated from github.com)

Add alignment possibilities left, right and center

  • update docs
  • update examples
Add alignment possibilities left, right and center * update docs * update examples
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-01-15 00:41:52 +01:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

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:

  • Renamed the message parameter to message_left across all public methods and added message_center and message_right parameters
  • Updated progress bar rendering to support aligned text with improved fill logic
  • Added CursorPos enum for controlling input cursor position in interactive prompts
  • Updated documentation and examples to demonstrate the new alignment features

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
src/cliasi/cliasi.py Core implementation of alignment logic in __print and __format_progressbar_to_screen_width methods; updated all public method signatures
src/cliasi/constants.py Added CursorPos enum and modified download animation symbol
src/cliasi/init.py Exported CursorPos enum in public API
tests/test_cliasi.py Updated test calls to use new message_left parameter name
tests/test_alignment.py Added comprehensive test suite for alignment functionality
examples/*.py Updated examples to demonstrate alignment features
docs/source/*.rst Added documentation for alignment features and updated existing examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## 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:** - Renamed the `message` parameter to `message_left` across all public methods and added `message_center` and `message_right` parameters - Updated progress bar rendering to support aligned text with improved fill logic - Added `CursorPos` enum for controlling input cursor position in interactive prompts - Updated documentation and examples to demonstrate the new alignment features ### Reviewed changes Copilot reviewed 12 out of 13 changed files in this pull request and generated 16 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | src/cliasi/cliasi.py | Core implementation of alignment logic in `__print` and `__format_progressbar_to_screen_width` methods; updated all public method signatures | | src/cliasi/constants.py | Added `CursorPos` enum and modified download animation symbol | | src/cliasi/__init__.py | Exported `CursorPos` enum in public API | | tests/test_cliasi.py | Updated test calls to use new `message_left` parameter name | | tests/test_alignment.py | Added comprehensive test suite for alignment functionality | | examples/*.py | Updated examples to demonstrate alignment features | | docs/source/*.rst | Added documentation for alignment features and updated existing examples | </details> --- 💡 <a href="/IgnyteX-Labs/cliasi/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@ -38,9 +39,10 @@ Cliasi instance
-----------------
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:46 +01:00

The word "weather" should be "whether" in this context. "Weather" refers to atmospheric conditions, while "whether" introduces alternatives.

* :attr:`~cliasi.cliasi.Cliasi.messages_stay_in_one_line` - whether messages should stay in one line, see :ref:`instances`
The word "weather" should be "whether" in this context. "Weather" refers to atmospheric conditions, while "whether" introduces alternatives. ```suggestion * :attr:`~cliasi.cliasi.Cliasi.messages_stay_in_one_line` - whether messages should stay in one line, see :ref:`instances` ```
@ -43,7 +44,7 @@ Here is a quick example to get you started:
# Finish download
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:49 +01:00

The 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%"'.

  cli.success("Download complete!", message_right="100%")
The 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%"'. ```suggestion cli.success("Download complete!", message_right="100%") ```
@ -204,3 +213,55 @@ You can ask for user input, including passwords.
class="asciinema_demo-dark"
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:47 +01:00

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.

    If the left message goes too far and covers the middle one,
    or is too long or has newlines, all aligned messages will be printed
    one after the other on separate lines. ``right`` aligned text will
    first attempt to print to the right of the last line; if there is not enough
    space, it will also wrap onto a new line.
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. ```suggestion If the left message goes too far and covers the middle one, or is too long or has newlines, all aligned messages will be printed one after the other on separate lines. ``right`` aligned text will first attempt to print to the right of the last line; if there is not enough space, it will also wrap onto a new line. ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:50 +01:00

The phrase "If the left message goes to far" should be "If the left message goes too far" (two 'o's in "too").

    If the left message goes too far and covers the middle one
The phrase "If the left message goes to far" should be "If the left message goes too far" (two 'o's in "too"). ```suggestion If the left message goes too far and covers the middle one ```
@ -23,7 +23,7 @@ cli.newline()
cli.set_prefix("LINEBREAKS")
cli.message("LINEBREAK TEST\nSUCCESSFUL")
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:51 +01:00

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.

cli.message("LINEBREAK TEST\nSUCCESSFUL")
# Intentional space after '!' to test line-breaking / cutoff behavior.
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. ```suggestion cli.message("LINEBREAK TEST\nSUCCESSFUL") # Intentional space after '!' to test line-breaking / cutoff behavior. ```
@ -36,7 +37,8 @@ try:
rows = int(os.environ.get("LINES", 24))
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:51 +01:00

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."

        # - 1 to avoid printing to the terminal edge.
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." ```suggestion # - 1 to avoid printing to the terminal edge. ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:51 +01:00

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.

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.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:52 +01:00

The word "seperator" is misspelled throughout the codebase. It should be spelled "separator" (with an 'a', not an 'e').

        :param seperator: Separator between prefix and message
The word "seperator" is misspelled throughout the codebase. It should be spelled "separator" (with an 'a', not an 'e'). ```suggestion :param seperator: Separator between prefix and message ```
@ -136,48 +145,240 @@ class Cliasi:
self,
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:46 +01:00

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.

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_long
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:52 +01:00

The 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 like align="center" for clearer intent.

            message_left = None
The 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 like `align="center"` for clearer intent. ```suggestion message_left = None ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:46 +01:00

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.

            If messages don't fit into their sections
            or messages are multiline, they will be outputted one
            after the other (except for right aligned content)
            thus destroying any alignment.
        :param message_right:
            Message or bool flag to print on right side of terminal
            If messages don't fit into their sections
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. ```suggestion If messages don't fit into their sections or messages are multiline, they will be outputted one after the other (except for right aligned content) thus destroying any alignment. :param message_right: Message or bool flag to print on right side of terminal If messages don't fit into their sections ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:51 +01:00

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.

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 length
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:47 +01:00

The variable name "seperating_space" is misspelled. It should be "separating_space" (with an 'a', not an 'e').

            separating_space = (
                (1 if m_left else 0) + (1 if m_center else 0) + (1 if m_right else 0)
            )
            separating_space = max(0, separating_space - 1)
            content_total = m_left + m_center + m_right
            truncated = False

            if len(content_total) + separating_space > width:
The variable name "seperating_space" is misspelled. It should be "separating_space" (with an 'a', not an 'e'). ```suggestion separating_space = ( (1 if m_left else 0) + (1 if m_center else 0) + (1 if m_right else 0) ) separating_space = max(0, separating_space - 1) content_total = m_left + m_center + m_right truncated = False if len(content_total) + separating_space > width: ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:48 +01:00

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.

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]]] = [
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:52 +01:00

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.RIGHT and then at line 836 checks cursor_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.

class CursorPos(StrEnum):
    """Cursor positions for user input
    Useful in :meth:`~cliasi.cliasi.Cliasi.ask()` method."""

    LEFT = "LEFT"
    CENTER = "CENTER"
    RIGHT = "RIGHT"
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.RIGHT` and then at line 836 checks `cursor_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. ```suggestion class CursorPos(StrEnum): """Cursor positions for user input Useful in :meth:`~cliasi.cliasi.Cliasi.ask()` method.""" LEFT = "LEFT" CENTER = "CENTER" RIGHT = "RIGHT" ```
@ -87,3 +87,3 @@
"default": ANIMATIONS_SYMBOLS,
"download": [["🢓", "", "", "", "", "", "_", "_"]],
"download": [["°", "", "", "", "", "", "_", "_"]],
}
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-15 00:41:50 +01:00

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.

    "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. ```suggestion "download": [["🢓", "↧", "⭣", "⯯", "⤓", "⩡", "_", "_"]], ```
Sign in to join this conversation.
No description provided.