Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Sep 13, 2022

Conversation

shazron
Copy link
Contributor

@shazron shazron commented Jun 24, 2022

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 shazron changed the title feat: ability to set/override wordWrap and wrapOnBoundary options per cell feat: ability to set/override wordWrap and wrapOnWordBoundary options per cell Jun 25, 2022
@shazron shazron marked this pull request as ready for review June 25, 2022 12:40
@shazron
Copy link
Contributor Author

shazron commented Jun 25, 2022

Unit tests added.

@shazron
Copy link
Contributor Author

shazron commented Jun 25, 2022

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
Copy link
Contributor Author

shazron commented Aug 29, 2022

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

@speedytwenty
Copy link
Collaborator

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.

@shazron
Copy link
Contributor Author

shazron commented Sep 6, 2022

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
Copy link
Contributor Author

shazron commented Sep 7, 2022

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

test.mp4

@speedytwenty
Copy link
Collaborator

speedytwenty commented Sep 10, 2022

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.

@shazron
Copy link
Contributor Author

shazron commented Sep 13, 2022

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

@speedytwenty speedytwenty merged commit ebe2a2f into cli-table:master Sep 13, 2022
@shazron shazron deleted the patch-1 branch September 13, 2022 16:16
@shazron
Copy link
Contributor Author

shazron commented Sep 15, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants