diff --git a/.npmignore b/.npmignore index 14f267e..56d42d1 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,4 @@ test .gitignore .sublimelinterrc .travis.yml -cli-helper.sublime-project +cli.sublime-project diff --git a/cli-helper.sublime-project b/cli.sublime-project similarity index 100% rename from cli-helper.sublime-project rename to cli.sublime-project diff --git a/index.js b/index.js index e5eb045..e164a28 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,17 @@ //-------------------------------------------------------- -//-- CLI helper +//-- CLI utilities //-------------------------------------------------------- 'use strict'; const echo = console.log; // eslint-disable-line no-console -const os = require('os'); -const path = require('path'); -const readPkgUp = require('read-pkg-up'); -const chalk = require('chalk'); -const pad = require('pad'); +const os = require('os'); +const path = require('path'); +const readPkgUp = require('read-pkg-up'); +const chalk = require('chalk'); +const pad = require('pad'); +// const widestLine = require('widest-line'); +// const stringWidth = require('string-width'); delete require.cache[__filename]; const pkgPath = path.dirname(module.parent.filename); @@ -21,7 +23,7 @@ const { pkg } = readPkgUp.sync({ cwd:pkgPath }); //-- Static properties -const STATIC = global.___AbsolunetCLIHelper___ ? global.___AbsolunetCLIHelper___ : global.___AbsolunetCLIHelper___ = { +const STATIC = global.___AbsolunetCli___ ? global.___AbsolunetCli___ : global.___AbsolunetCli___ = { commands: {}, taskWidth: {}, fullUsage: {}, @@ -43,7 +45,7 @@ const printCmd = (cmd, width = STATIC.baseWidth, spacer = 1) => { -module.exports = class CLIHelper { +module.exports = class Cli { //-- Usager helpers static get PLACEHOLDER() { @@ -59,7 +61,7 @@ module.exports = class CLIHelper { } static optionalPlaceholder(name) { - return `${chalk.reset('[')}${CLIHelper.placeholder(name)}${chalk.reset(']')}`; + return `${chalk.reset('[')}${this.placeholder(name)}${chalk.reset(']')}`; } @@ -113,8 +115,8 @@ module.exports = class CLIHelper { //-- Show task usage and die - static showTaskUsage(cli) { - echo(`\n${CLIHelper.getTaskUsage(cli.input[0])}`); + static showTaskUsage(meowCli) { + echo(`\n${this.getTaskUsage(meowCli.input[0])}`); process.exit(2); // eslint-disable-line no-process-exit } @@ -132,16 +134,16 @@ module.exports = class CLIHelper { } //-- Refuse flags - static refuseFlags(cli) { - if (Object.keys(cli.flags).length) { - CLIHelper.showTaskUsage(cli); + static refuseFlags(meowCli) { + if (Object.keys(meowCli.flags).length) { + this.showTaskUsage(meowCli); } } //-- Refuse flags & arguments - static refuseFlagsAndArguments(cli) { - if (cli.input.length > 1 || Object.keys(cli.flags).length) { - CLIHelper.showTaskUsage(cli); + static refuseFlagsAndArguments(meowCli) { + if (meowCli.input.length > 1 || Object.keys(meowCli.flags).length) { + this.showTaskUsage(meowCli); } } diff --git a/package.json b/package.json index 088755d..c93d3ba 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "@absolunet/cli-helper", + "name": "@absolunet/cli", "version": "0.0.1", - "description": "CLI helper", + "description": "CLI utilities", "definition": "", - "homepage": "https://github.com/absolunet/cli-helper", + "homepage": "https://github.com/absolunet/node-cli", "author": { "name": "Absolunet", "url": "http://absolunet.com/" }, "license": "MIT", - "repository": { "url": "git://github.com/absolunet/cli-helper.git", "type":"git" }, - "bugs": { "url": "https://github.com/absolunet/cli-helper/issues" }, + "repository": { "url": "git://github.com/absolunet/node-cli.git", "type":"git" }, + "bugs": { "url": "https://github.com/absolunet/node-cli/issues" }, "engines": { "node": ">= 7.7.3" }, "scripts": { diff --git a/readme.md b/readme.md index 68e51da..b2ecdd1 100644 --- a/readme.md +++ b/readme.md @@ -1,11 +1,11 @@ -# @absolunet/cli-helper +# @absolunet/cli -[![NPM version](https://img.shields.io/npm/v/@absolunet/cli-helper.svg)](https://www.npmjs.com/package/@absolunet/cli-helper) -[![Travis build](https://api.travis-ci.org/absolunet/cli-helper.svg?branch=master)](https://travis-ci.org/absolunet/cli-helper/builds) -[![Dependencies](https://david-dm.org/absolunet/cli-helper/status.svg)](https://david-dm.org/absolunet/cli-helper) -[![Dev dependencies](https://david-dm.org/absolunet/cli-helper/dev-status.svg)](https://david-dm.org/absolunet/cli-helper?type=dev) +[![NPM version](https://img.shields.io/npm/v/@absolunet/cli.svg)](https://www.npmjs.com/package/@absolunet/cli) +[![Travis build](https://api.travis-ci.org/absolunet/node-cli.svg?branch=master)](https://travis-ci.org/absolunet/node-cli/builds) +[![Dependencies](https://david-dm.org/absolunet/node-cli/status.svg)](https://david-dm.org/absolunet/node-cli) +[![Dev dependencies](https://david-dm.org/absolunet/node-cli/dev-status.svg)](https://david-dm.org/absolunet/node-cli?type=dev) -> CLI helper +> CLI utilities ## License -See the [license](https://github.com/absolunet/cli-helper/blob/master/license). +See the [license](https://github.com/absolunet/node-cli/blob/master/license).