Nukesor / pueue

:stars: Manage your shell commands.
MIT License
4.68k stars 128 forks source link

[Bug] The coloum width of the `pueue status` output table is fixed to 1 #502

Closed magicwenli closed 4 months ago

magicwenli commented 4 months ago

Describe the bug

I was tring use pueue in an android device with adb shell. The output table of pueue status and pueue log seems to be squeezed.

The wired thing is, when I tried comfy-table's example binary readme_table. It is worked!

Steps to reproduce

  1. copy pueue pueued to android devices
  2. init the daemon and add a task to pueue
  3. pueue status

Debug logs (if relevant)

~ ❯ adb shell
* daemon not running; starting now at tcp:5037
* daemon started successfully
sh-5.0# 
sh-5.0# 
sh-5.0# echo $SHELL
/bin/sh
sh-5.0# pueue add pwd
New task added (id 0).
sh-5.0# pueue status
Group "default" (1 parallel): running
───────────────────────
 I   S   C   P   S   E
 d   t   o   a   t   n
     a   m   t   a   d
     t   m   h   r
     u   a       t
     s   n
         d
═══════════════════════
 0   S   p   /   1   1
     u   w       2   2
     c   d       :   :
     c           4   4
     e           7   7
     s           :   :
     s           0   0
                 4   4
sh-5.0# ./readme_table
┌─────────────────────┬───────────────────────────────┬────────────────────────┐
│ Header1             ┆ Header2                       ┆ Header3                │
╞═════════════════════╪═══════════════════════════════╪════════════════════════╡
│ This is a bold text ┆ This is a green text          ┆ This one has black     │
│                     ┆                               ┆ background             │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Blinky boi          ┆ This table's content is       ┆ COMBINE ALL THE THINGS │
│                     ┆ dynamically arranged. The     ┆                        │
│                     ┆ table is exactly 80           ┆                        │
│                     ┆ characters wide.              ┆                        │
│                     ┆ Here comes a reallylongwordth ┆                        │
│                     ┆ atshoulddynamicallywrap       ┆                        │
└─────────────────────┴───────────────────────────────┴────────────────────────┘
sh-5.0# /bin/sh --help
GNU bash, version 5.0.18(1)-release-(aarch64-unisoc-linux-gnu)
Usage:  /bin/sh [GNU long option] [option] ...
        /bin/sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --pretty-print
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -ilrsD or -c command or -O shopt_option         (invocation only)
        -abefhkmnptuvxBCHP or -o option
Type `/bin/sh -c "help set"' for more information about shell options.
Type `/bin/sh -c help' for more information about shell builtin commands.
Use the `bashbug' command to report bugs.

bash home page: <http://www.gnu.org/software/bash>
General help using GNU software: <http://www.gnu.org/gethelp/>
sh-5.0#

Operating system

Android

Pueue version

v3.3.3

Additional context

No response

magicwenli commented 4 months ago

Sorry, I found the answer almost immediately. It was caused by the problem of Shell's LINES COLUMNS environment variable.

After doing resize, the table shows great!

~ ❯ adb shell
sh-5.0# echo $COLUMNS $LINES
80 24
sh-5.0# resize
COLUMNS=117;LINES=21;export COLUMNS LINES;
sh-5.0# eval `resize`
sh-5.0# 
sh-5.0# pueue status
Group "default" (1 parallel): running
─────────────────────────────────────────────────────
 Id   Status    Command   Path   Start      End      
═════════════════════════════════════════════════════
 0    Success   pwd       /      12:47:04   12:47:04 
─────────────────────────────────────────────────────
sh-5.0# 
Nukesor commented 4 months ago

That's what I would have expected as well (the terminal not properly reporting its dimensions) ^^.

comfy-table uses the current tty's width to determine the best way to render it. If the terminal is way to small, the columns fall back to the smallest possible width, which is 1.

The comfy-table readme example works fine, as the table has a fixed width of 80 and doesn't actually use the current terminal's width.

Closing as solved :)