22 Star 218 Fork 230

记得要让着本宝宝/ckjcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.idea
_includes
_layouts
_posts
css
fonts
img
js
less
node_modules
.bin
abbrev
align-text
amdefine
ansi-regex
ansi-styles
argparse
asn1
assert-plus
async
aws-sign2
boom
browserify-zlib
buffer-from
camelcase
center-align
chalk
clean-css
cliui
test
.coveralls.yml
.npmignore
.travis.yml
LICENSE.txt
README.md
index.js
package.json
coffee-script
colors
combined-stream
commander
concat-stream
core-util-is
cryptiles
ctype
dateformat
debug
decamelize
deep-equal
defined
delayed-stream
escape-string-regexp
esprima
eventemitter2
exit
faye-websocket
figures
findup-sync
forever-agent
form-data
gaze
getobject
glob
globule
graceful-fs
grunt-contrib-less/node_modules
grunt-contrib-uglify/node_modules
grunt-contrib-watch/node_modules
grunt-legacy-log-utils
grunt-legacy-log
grunt-legacy-util
gzip-size
has-ansi
has-color
hawk
hoek
hooker
http-signature
iconv-lite
inherits
ip-regex
is-buffer
isarray
js-yaml
json-stringify-safe
jsonify
kind-of
lazy-cache
less
lodash
longest
lru-cache
maxmin
mime-types
mime
minimatch
minimist
mkdirp
natives
node-uuid
nopt
noptify
oauth-sign
object-assign
pako
pretty-bytes
process-nextick-args
psl
punycode
qs
readable-stream
repeat-string
request
right-align
rimraf
safe-buffer
sigmund
sntp
source-map
string_decoder
stringstream
strip-ansi
supports-color
tape
tiny-lr-fork
tough-cookie
tunnel-agent
typedarray
uglify-js
uglify-to-browserify
underscore.string
underscore
util-deprecate
which
window-size
wordwrap
yargs
zlib-browserify
pwa
.gitignore
404.html
ChengKeJ.github.io.iml
Graph Bed.md
Gruntfile.js
LICENSE
README.md
_config.yml
about.html
chengkej.io.iml
codecov.yml
feed.xml
index.html
offline.html
package-lock.json
package.json
sw.js
tags.html
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

cliui

Build Status Coverage Status NPM version

easily create complex multi-column command-line-interfaces.

Example

var ui = require('cliui')({
  width: 80
})

ui.div('Usage: $0 [command] [options]')

ui.div({
  text: 'Options:',
  padding: [2, 0, 2, 0]
})

ui.div(
  {
    text: "-f, --file",
    width: 40,
    padding: [0, 4, 0, 4]
  },
  {
    text: "the file to load",
    width: 25
  },
  {
    text: "[required]",
    align: 'right'
  }
)

console.log(ui.toString())

Layout DSL

cliui exposes a simple layout DSL:

If you create a single ui.row, passing a string rather than an object:

  • \n: characters will be interpreted as new rows.
  • \t: characters will be interpreted as new columns.
  • : characters will be interpreted as padding.

as an example...

var ui = require('./')({
  width: 60
})

ui.div(
  'Usage: node ./bin/foo.js\n' +
  '  <regex>\t  provide a regex\n' +
  '  <glob>\t  provide a glob\t [required]'
)

console.log(ui.toString())

will output:

Usage: node ./bin/foo.js
  <regex>  provide a regex
  <glob>   provide a glob          [required]

Methods

cliui = require('cliui')

cliui({width: integer})

Specify the maximum width of the UI being generated.

cliui({wrap: boolean})

Enable or disable the wrapping of text in a column.

cliui.div(column, column, column)

Create a row with any number of columns, a column can either be a string, or an object with the following options:

  • width: the width of a column.
  • align: alignment, right or center.
  • padding: [top, right, bottom, left].

cliui.span(column, column, column)

Similar to div, except the next row will be appended without a new line being created.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/ckjcode/ckjcode.git
git@gitee.com:ckjcode/ckjcode.git
ckjcode
ckjcode
ckjcode
master

搜索帮助