Skip to content

Commit

Permalink
Renamed name to title.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed May 19, 2017
1 parent 44b780b commit e1e296f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 26 deletions.
20 changes: 10 additions & 10 deletions dist/vorpal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function Vorpal() {
// Exposed through vorpal.version(str);
this._version = '';

// Program name
this._name = '';
// Program title
this._title = '';

// Program description
this._description = '';
Expand Down Expand Up @@ -197,15 +197,15 @@ vorpal.version = function (version) {
};

/**
* Sets the name of your application.
* Sets the title of your application.
*
* @param {String} name
* @param {String} title
* @return {Vorpal}
* @api public
*/

vorpal.name = function (name) {
this._name = name;
vorpal.title = function (title) {
this._title = title;
return this;
};

Expand Down Expand Up @@ -1186,14 +1186,14 @@ vorpal._helpHeader = function (hideTitle) {
}

// Only show under specific conditions
if (this._name && !hideTitle) {
var name = this._name;
if (this._title && !hideTitle) {
var title = this._title;

if (this._version) {
name += ' v' + this._version;
title += ' v' + this._version;
}

header.push(VorpalUtil.padRow(name));
header.push(VorpalUtil.padRow(title));

if (this._description) {
var descWidth = process.stdout.columns * 0.75; // Only 75% of the screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var vorpal = require('./../../')();
var chalk = vorpal.chalk;

vorpal
.name(chalk.magenta('Vorpal'))
.title(chalk.magenta('Vorpal'))
.version('1.4.0')
.description(chalk.cyan('Conquer the command-line.'))
.banner(chalk.gray(` (O)
Expand Down
27 changes: 16 additions & 11 deletions lib/vorpal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function Vorpal() {
// Exposed through vorpal.version(str);
this._version = '';

// Program name
this._name = '';
// Program title
this._title = '';

// Program description
this._description = '';
Expand Down Expand Up @@ -197,15 +197,15 @@ vorpal.version = function (version) {
};

/**
* Sets the name of your application.
* Sets the title of your application.
*
* @param {String} name
* @param {String} title
* @return {Vorpal}
* @api public
*/

vorpal.name = function (name) {
this._name = name;
vorpal.title = function (title) {
this._title = title;
return this;
};

Expand Down Expand Up @@ -1186,7 +1186,12 @@ vorpal._commandHelp = function (command) {
'' :
' Command Groups:\n\n' + groups.join('\n') + '\n';

var results = String(this._helpHeader(!!invalidString) + invalidString + commandsString + '\n' + groupsString)
var results = String(
this._helpHeader(!!invalidString) +
invalidString +
commandsString + '\n' +
groupsString
)
.replace(/\n\n\n/g, '\n\n')
.replace(/\n\n$/, '\n');

Expand All @@ -1201,14 +1206,14 @@ vorpal._helpHeader = function (hideTitle) {
}

// Only show under specific conditions
if (this._name && !hideTitle) {
var name = this._name;
if (this._title && !hideTitle) {
var title = this._title;

if (this._version) {
name += ' v' + this._version;
title += ' v' + this._version;
}

header.push(VorpalUtil.padRow(name));
header.push(VorpalUtil.padRow(title));

if (this._description) {
var descWidth = process.stdout.columns * 0.75; // Only 75% of the screen
Expand Down
8 changes: 4 additions & 4 deletions test/vorpal.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ describe('help menu', function () {
});
});

describe('metadata', function () {
describe('descriptors', function () {
var instance;

beforeEach(function () {
Expand All @@ -362,9 +362,9 @@ describe('metadata', function () {
assert.equal(instance._version, '1.2.3');
});

it('sets the name', function () {
instance.name('Vorpal');
assert.equal(instance._name, 'Vorpal');
it('sets the title', function () {
instance.title('Vorpal');
assert.equal(instance._title, 'Vorpal');
});

it('sets the description', function () {
Expand Down

0 comments on commit e1e296f

Please sign in to comment.