Skip to content

Commit 65483ff

Browse files
committed
fix: rename internal key: name —> bin
- Closes #24
1 parent 00d355b commit 65483ff

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

lib/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class Sade {
99
let [bin, ...rest] = name.split(/\s+/);
1010
isOne = isOne || rest.length > 0;
1111

12-
this.tree = {};
13-
this.name = bin;
14-
this.default = '';
12+
this.bin = bin;
1513
this.ver = '0.0.0';
14+
this.default = '';
15+
this.tree = {};
1616
// set internal shapes;
1717
this.command(ALL);
1818
this.command([DEF].concat(isOne ? rest : '<command>').join(' '));
@@ -100,7 +100,7 @@ class Sade {
100100
let alias = { h:'help', v:'version' };
101101
let argv = mri(arr.slice(offset), { alias });
102102
let isSingle = this.single;
103-
let bin = this.name;
103+
let bin = this.bin;
104104
let tmp, name = '';
105105
let isVoid, cmd;
106106

@@ -169,12 +169,12 @@ class Sade {
169169

170170
help(str) {
171171
console.log(
172-
$.help(this.name, this.tree, str || DEF, this.single)
172+
$.help(this.bin, this.tree, str || DEF, this.single)
173173
);
174174
}
175175

176176
_version() {
177-
console.log(`${this.name}, ${this.ver}`);
177+
console.log(`${this.bin}, ${this.ver}`);
178178
}
179179
}
180180

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('sade', t => {
1717
test('sade()', t => {
1818
let ctx = sade('foo');
1919
t.ok(ctx.constructor && ctx.constructor.name === 'Sade', 'returns instance of Sade');
20-
t.is(ctx.name, 'foo', 'sets Program name to `foo`');
20+
t.is(ctx.bin, 'foo', 'sets Program name to `foo`');
2121
t.is(ctx.ver, '0.0.0', 'defaults `ver` to `0.0.0`');
2222
t.is(ctx.curr, '', 'is empty command-name scope');
2323
t.is(ctx.default, '', 'has no default command (yet)');

test/utils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ test('utils.sentences', t => {
3838
});
3939

4040
test('utils.help', t => {
41-
let { name, tree } = sade('foo').describe('global foo').command('bar', 'Hello. World.').command('fizz <buzz>');
41+
let { bin, tree } = sade('foo').describe('global foo').command('bar', 'Hello. World.').command('fizz <buzz>');
4242

43-
let foo = $.help(name, tree, '__default__'); // global, 1 or 0 lines of desc per command
43+
let foo = $.help(bin, tree, '__default__'); // global, 1 or 0 lines of desc per command
4444
t.is(foo, '\n Description\n global foo\n\n Usage\n $ foo <command> [options]\n\n Available Commands\n bar Hello.\n fizz \n\n For more info, run any command with the `--help` flag\n $ foo bar --help\n $ foo fizz --help\n\n Options\n -v, --version Displays current version\n -h, --help Displays this message\n');
4545

46-
let bar = $.help(name, tree, 'bar'); // two-line description
46+
let bar = $.help(bin, tree, 'bar'); // two-line description
4747
t.is(bar, '\n Description\n Hello.\n World.\n\n Usage\n $ foo bar [options]\n\n Options\n -h, --help Displays this message\n');
4848

49-
let fizz = $.help(name, tree, 'fizz'); // no description
49+
let fizz = $.help(bin, tree, 'fizz'); // no description
5050
t.is(fizz, '\n Usage\n $ foo fizz <buzz> [options]\n\n Options\n -h, --help Displays this message\n');
5151

5252
t.end();
5353
});
5454

5555
test('utils.help :: single', t => {
56-
let { name, tree } = sade('foo <bar> [baz]', true).describe('global foo').option('-p, --port', 'Custom port value', 8000);
56+
let { bin, tree } = sade('foo <bar> [baz]', true).describe('global foo').option('-p, --port', 'Custom port value', 8000);
5757

58-
let text = $.help(name, tree, '__default__', true);
58+
let text = $.help(bin, tree, '__default__', true);
5959
t.is(text, '\n Description\n global foo\n\n Usage\n $ foo <bar> [baz] [options]\n\n Options\n -p, --port Custom port value (default 8000)\n -v, --version Displays current version\n -h, --help Displays this message\n');
6060

6161
t.end();

0 commit comments

Comments
 (0)