Skip to content

Commit 9973491

Browse files
committedJan 4, 2020
Change min offset in help
1 parent 1e0db9c commit 9973491

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed
 

‎lib/help.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const MAX_LINE_WIDTH = process.stdout.columns || 200;
2-
const MIN_OFFSET = 25;
2+
const MIN_OFFSET = 20;
33
const reAstral = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
44
const ansiRegex = /\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[m|K]/g;
55
const byName = (a, b) => a.name > b.name || -(a.name < b.name);
@@ -67,7 +67,7 @@ function args(params, fn = s => s) {
6767
}
6868

6969
function formatLines(lines) {
70-
const maxNameLength = Math.max(MIN_OFFSET - 2, ...lines.map(line => stringLength(line.name)));
70+
const maxNameLength = Math.max(MIN_OFFSET, ...lines.map(line => stringLength(line.name)));
7171

7272
return lines.map(line => (
7373
' ' + pad(maxNameLength, line.name) +

‎test/command-help.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Command help', () => {
2323
'',
2424
'Options:',
2525
'',
26-
' \u001b[33m-h\u001b[39m, \u001b[33m--help\u001b[39m Output usage information',
26+
' \u001b[33m-h\u001b[39m, \u001b[33m--help\u001b[39m Output usage information',
2727
'',
2828
''
2929
].join('\n'));
@@ -42,8 +42,8 @@ describe('Command help', () => {
4242
'',
4343
'Options:',
4444
'',
45-
' \u001b[33m--foo\u001b[39m Foo',
46-
' \u001b[33m--help\u001b[39m Output usage information',
45+
' \u001b[33m--foo\u001b[39m Foo',
46+
' \u001b[33m--help\u001b[39m Output usage information',
4747
'',
4848
''
4949
].join('\n'));
@@ -54,9 +54,12 @@ describe('Command help', () => {
5454
.command('test', '[qux]')
5555
.description('Test description')
5656
.option('-f, --foo', 'Foo')
57-
.option('--bar <baz>', 'Bar')
57+
.option('--bar <baz>', 'Bar', 8080)
5858
.command('nested')
5959
.end()
60+
.command('nested2')
61+
.description('with description')
62+
.end()
6063
.run(['--help']);
6164

6265
assert.equal(inspect.output, [
@@ -68,13 +71,14 @@ describe('Command help', () => {
6871
'',
6972
'Commands:',
7073
'',
71-
' \u001b[32mnested\u001b[39m ',
74+
' \u001b[32mnested\u001b[39m ',
75+
' \u001b[32mnested2\u001b[39m with description',
7276
'',
7377
'Options:',
7478
'',
75-
' \u001b[33m--bar\u001b[39m <baz> Bar',
76-
' \u001b[33m-f\u001b[39m, \u001b[33m--foo\u001b[39m Foo',
77-
' \u001b[33m-h\u001b[39m, \u001b[33m--help\u001b[39m Output usage information',
79+
' \u001b[33m--bar\u001b[39m <baz> Bar',
80+
' \u001b[33m-f\u001b[39m, \u001b[33m--foo\u001b[39m Foo',
81+
' \u001b[33m-h\u001b[39m, \u001b[33m--help\u001b[39m Output usage information',
7882
'',
7983
''
8084
].join('\n'));
@@ -96,8 +100,8 @@ describe('Command help', () => {
96100
'',
97101
'Options:',
98102
'',
99-
' \u001b[33m--bar\u001b[39m <baz> Bar',
100-
' \u001b[33m-h\u001b[39m, \u001b[33m--help\u001b[39m Output usage information',
103+
' \u001b[33m--bar\u001b[39m <baz> Bar',
104+
' \u001b[33m-h\u001b[39m, \u001b[33m--help\u001b[39m Output usage information',
101105
'',
102106
''
103107
].join('\n'));
@@ -117,8 +121,8 @@ describe('Command help', () => {
117121
'',
118122
'Options:',
119123
'',
120-
' \u001b[33m-f\u001b[39m, \u001b[33m--foo\u001b[39m Foo',
121-
' \u001b[33m-h\u001b[39m, \u001b[33m--help\u001b[39m Output usage information',
124+
' \u001b[33m-f\u001b[39m, \u001b[33m--foo\u001b[39m Foo',
125+
' \u001b[33m-h\u001b[39m, \u001b[33m--help\u001b[39m Output usage information',
122126
'',
123127
''
124128
].join('\n'));

0 commit comments

Comments
 (0)
Please sign in to comment.