Skip to content

CJK chracters causing result table columns to shift #1438

@JokerQyou

Description

@JokerQyou

Describe the bug

When file / directory names contains CJK chracters, each chracter takes space of two ASCII chracters, the table header does not take this into account, and sometimes may causing confusion.

To Reproduce

Run the following command to reproduce:

pyinfra hosts/test-machine.py exec -- echo 随便输出一些中文试试
--> Loading config...
--> Loading inventory...
--> Connecting to hosts...
    [x64.test-machine] Connected

--> Preparing exec operation...
    [x64.test-machine] Ready: shell

--> Beginning operation run...
--> Starting operation: server.shell (echo 随便输出一些中文试试)
[x64.test-machine] 随便输出一些中文试试
    [x64.test-machine] Success

--> Results:
    Operation                        Hosts   Success   Error   No Change
    server.shell (echo 随便输出一些中文试试)   1       1         -       -
    Grand total                      1       1         -       -

--> Disconnecting from hosts...

You can see in the Results table, the server.shell line does not match table header, and might confuse user into thinking the command has failed.

Image

Expected behavior

I expect the table header columns to shift to the right, each column should use the longest vallue of that field to decide its position.

Alternatively, it might help to render the table with cell borders.

Meta

Pyinfra support meta:

    System: Darwin
      Platform: macOS-14.7.6-arm64-arm-64bit
      Release: 23.6.0
      Machine: arm64
    pyinfra: v3.4.1
      click: v8.1.7
      click: v8.1.7
      click: v8.1.7
      distro: v1.8.0
      gevent: v23.9.1
      jinja2: v3.1.2
      packaging: v25.0
      paramiko: v2.12.0
      python-dateutil: v2.8.2
      pywinrm: v0.4.3
      typeguard: v4.4.4
      typing-extensions: v4.14.1
      wheel: v0.42.0
    Executable: ~/.miniforge3/envs/<redacted>/bin/pyinfra
    Python: 3.12.0 (CPython, Clang 15.0.7 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLICLI mode specific issues.bugLabel for all kind of bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions