microsoft / microsoft/knack

Set column width for tabular output format

Open
#270 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
358
Forks
101
PR merge metrics
No merged PRs in 30d

Description

I am adding some code to an Azure extension and need to display a 130 character long hexadecimals string.
Azure CLI uses Knack which in turn uses the 'tabulate' library to print the table output format in the terminals.
Tabulate provides a maxcolwidths argument which specifies the max width for it's respective column. However, knack does not use this argument, nor does it provide a way to configure this.

I have a 130-character hexadecimal string which needs to be displayed in tabular format. However, since knack does not specify the column width, the table outputs is not easily readable on a smaller size terminal.
image

I am looking for something like this (test code and I set the maxcolwdiths argument to 30 here)

  Length  Value
--------  ------------------------------
     130  1234567890ABCDEF1234567890ABCD
          EF1234567890ABCDEF1234567890AB
          CDEF1234567890ABCDEF1234567890
          ABCDEF1234567890ABCDEF12345678
          90ABCDEF
     130  1234567890ABCDEF1234567890ABCD
          EF1234567890ABCDEF1234567890AB
          CDEF1234567890ABCDEF1234567890
          ABCDEF1234567890ABCDEF12345678
          90ABCDEF
      10  1234567890

Is there any way that knack provides to configure the maxcolwidths argument from Azure CLI?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Knack's tabular output path and its use of the Python tabulate library; the issue names no file or test. Confirm the available configuration entry point, then verify that a configured maximum column width wraps long values in tabular output as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.