refactor(cli): use package to render boxes in the console output

This avoids having to figure out the length of each line manually.
pull/107/head
Romain 6 years ago
parent 24790c075c
commit 7edf3bbf15

@ -1,8 +1,14 @@
const chalk = require('chalk')
const boxen = require('boxen')
const DOCS_URL = chalk.green('https://thumbsup.github.io/docs')
const ISSUES_URL = chalk.green('https://github.com/thumbsup/thumbsup/issues')
function box (str) {
const lines = str.split('\n').map(s => ` ${s} `).join('\n')
return boxen(lines)
}
exports.USAGE = () => `
Usages:
thumbsup [required] [options]
@ -15,38 +21,30 @@ per argument, not including the leading "--". For example:
{ "sort-albums-by": "start-date" }
`
exports.SUCCESS = (stats) => `
Gallery generated successfully
exports.SUCCESS = (stats) => box(`
Gallery generated successfully!
${stats.albums} albums, ${stats.photos} photos, ${stats.videos} videos
`
`)
exports.GREETING = () => `
Thanks for using thumbsup!
Don't forget to check out the docs at ${DOCS_URL}.
When building a gallery, thumbsup reports anonymous stats such as the OS and
gallery size. This is used to understand usage patterns & guide development
effort. You can disable usage reporting by specifying --no-usage-stats.
This welcome message will not be shown again for this gallery.
Enjoy!
`
exports.GREETING = () => box(`
Thanks for using thumbsup!
exports.SORRY = () => `
Something went wrong!
An unexpected error occurred and the gallery didn't build successfully.
This is most likely an edge-case that hasn't been tested before.
To help improve thumbsup and hopefully resolve your problem,
please raise an issue at ${ISSUES_URL}.
`
Don't forget to check out the docs at ${DOCS_URL}.
When building a gallery, thumbsup reports anonymous stats such as the OS and
gallery size. This is used to understand usage patterns & guide development
effort. You can disable usage reporting by specifying --no-usage-stats.
This welcome message will not be shown again for this gallery.
Enjoy!
`)
exports.SORRY = () => box(`
Something went wrong!
An unexpected error occurred and the gallery didn't build successfully.
This is most likely an edge-case that hasn't been tested before.
To help improve thumbsup and hopefully resolve your problem,
please raise an issue at ${ISSUES_URL}.
`)

10509
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -31,6 +31,7 @@
"JSONStream": "^1.3.2",
"async": "^2.5.0",
"better-sqlite3": "^4.1.0",
"boxen": "^1.3.0",
"chalk": "^2.4.1",
"command-exists": "^1.2.6",
"debug": "^3.1.0",

Loading…
Cancel
Save