cli-table3 icon indicating copy to clipboard operation
cli-table3 copied to clipboard

feat: ability to set/override wordWrap and wrapOnWordBoundary options per cell

Open shazron opened this issue 3 years ago • 2 comments

Description

This adds the ability to set wordWrap and wrapOnWordBoundary options per cell, instead of it being set globally via the table options.

Use case is for when you want one column to have wrapOnWordBoundary=false, and another column with wrapOnWordBoundary=true (see screenshot and sample code)

Sample Code

const Table = require("cli-table3");

let table = new Table({
  style: { head: [], border: [] },
  colWidths: [15, 50],
  wordWrap: true,
  wrapOnWordBoundary: true
});

table.push(
  ['URLs', 'Description'],
  [{ content: 'https://en.wikipedia.org/wiki/Voyager_program', wrapOnWordBoundary: false }, { content: 'The Voyager program is an American scientific program that employs two robotic interstellar probes, Voyager 1 and Voyager 2. They were launched in 1977 to take advantage of a favorable alignment of Jupiter and Saturn, to fly near them while collecting data for transmission back to Earth. After launch the decision was taken to send Voyager 2 near Uranus and Neptune to collect data for transmission back to Earth.'}],
  [{ content: 'https://en.wikipedia.org/wiki/SpaceX', wrapOnWordBoundary: false }, { content: 'Space Exploration Technologies Corp. (doing business as SpaceX) is an American spacecraft manufacturer, space launch provider, and a satellite communications corporation headquartered in Hawthorne, California. SpaceX was founded in 2002 by Elon Musk, with the goal of reducing space transportation costs to enable the colonization of Mars. SpaceX manufactures the Falcon 9 and Falcon Heavy launch vehicles, several rocket engines, Cargo Dragon, crew spacecraft, and Starlink communications satellites.' }]
);

console.log(table.toString())

Screenshot

image

shazron avatar Jun 24 '22 17:06 shazron

Unit tests added.

shazron avatar Jun 25 '22 12:06 shazron

I know there is the hyperlink option, but you can imagine instead of urls, there could be a long identifier in the column, like npm package names, etc

shazron avatar Jun 25 '22 13:06 shazron

@speedytwenty any chance of this getting pulled in and released? Thanks!

shazron avatar Aug 29 '22 14:08 shazron

The CI tests didn't execute for this PR. Not sure why or how to induce them. Must be something with first-time contributors and github. Once we can trigger these so we have a record of passing tests, I can get it merged.

speedytwenty avatar Sep 06 '22 03:09 speedytwenty

You have to configure your test.yml like so, with the pull_request section: https://github.com/adobe/aio-cli-plugin-app/blob/8ca3187eb887336a6f4246e8a586ab24dd99d3a7/.github/workflows/node.js.yml#L6-L10

Here's the whole reference for pull_request (which you have empty) in your test.yml: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request

shazron avatar Sep 06 '22 06:09 shazron

FWIW, until you've fixed up your CI issue, I have included the video of my tests passing:

https://user-images.githubusercontent.com/36107/188873002-1f657985-717c-4154-8c7f-b1371bf0c1e0.mp4

shazron avatar Sep 07 '22 11:09 shazron

I apologize for the delay between responses. You've caught me during my peak busy time of the year.

I'm quite sure the CI issue is a github bug. I had glanced at the PR before you added tests, and there was an option to approve you as a new contributor to execute the GA workflow but that option disappeared after you pushed another commit.

I suggest we try this:

  1. Squash your commits and let's see if the approve option returns.
  2. If not, open a new PR and I should be able to approve it then.

speedytwenty avatar Sep 10 '22 04:09 speedytwenty

@speedytwenty thanks! I've squashed all 3 commits into one. I see "1 workflow awaiting approval" so I think it may have worked

shazron avatar Sep 13 '22 14:09 shazron

@speedytwenty thank you for the merge! any chance there can be a new release?

shazron avatar Sep 15 '22 07:09 shazron