Skip to content

v0.3.4

Choose a tag to compare

@oscarhugopaz oscarhugopaz released this 05 Jun 02:36
· 20 commits to main since this release

Patch release. Fixes four classes of failure surfaced by running
every command against a real MainWP Dashboard.

  1. Default gum output was unimplemented (lib/output.sh)
    mainwp_render_table had branches for json and plain, but
    the default 'table' branch (with gum installed) fell straight
    through to return 0 without printing anything. Wire up
    gum table --separator ';' for the styled case, and wrap the
    gum call in a try-or-fallback so any gum failure silently
    degrades to plain text.

  2. gum broke on TTY-less shells (lib/output.sh)
    gum table tries to open /dev/tty for its alternate-screen
    buffer and exits non-zero, swallowing the output. The fix:
    only attempt the gum path when [[ -t 1 ]]. The same gate
    applies to mainwp_render_object, which used column -t and
    died with 'line too long' on any payload containing a long
    value (URL, embedded JSON). Replace with a printf-width
    formatter that has no line-length limit.

  3. List endpoints with array values printed multi-line junk
    (lib/output.sh). The plain and gum paths now use
    .permissions | join(", ") so
    permissions: ["Read", "Write & Delete"] becomes a single
    comma-separated cell that fits one row.

  4. The API has at least four response shapes; the extractor
    only handled one
    (lib/commands/_common.sh). The new
    _mainwp_extract_list handles:

    • a bare array [a, b]
    • {data: [a, b]} unwrap
    • {data: {k: [users]}} (e.g. /users) recurse
    • {k: obj, k: obj, ...} (e.g. /tags) flatten
      An earlier revision also embedded the jq program inside
      $'...\n\t...', which under certain quoting combinations left
      the \n and \t markers literal and made jq silently return
      empty. Use one-line jq programs on stdin to avoid the trap.

In addition:

  • lib/api.sh: mainwp_api_get and mainwp_api_delete no
    longer have an implicit body argument. Their signatures
    are mainwp_api_get path extras... where every extra
    positional is treated as a query-string pair. Same root
    cause as the earlier init per_page=1 bug: the third
    positional was the body, not a query arg, and GET endpoints
    were silently treating the query filter as the request body
    and returning 400.
  • lib/commands/users.sh: cmd_users_list was bypassing
    the extractor entirely. Now it goes through
    _mainwp_extract_list, so users show up as a real table
    with a site column.
  • lib/commands/sites.sh: _mainwp_extract_sites is now
    a thin shim around _mainwp_extract_list.

Verified end-to-end against the real dashboard (26/27 read
endpoints passing; the one remaining failure, posts list --websites 45, is a server-side HTTP 500 and is not a CLI
issue). 61 smoke tests, all passing.