Skip to content

Commit 40dd36d

Browse files
committed
Print help text when not provided any commands or flags
1 parent 95b923d commit 40dd36d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

bin/cli

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,14 @@ function main() {
102102

103103
// Get any provided command-line options:
104104
flags = cli.flags();
105+
if ( flags.help || flags.version ) {
106+
return;
107+
}
105108

106109
// Extract the command:
110+
if ( args.length === 0 ) {
111+
return cli.help();
112+
}
107113
if ( args[ 0 ] === 'help' ) {
108114
if ( args.length === 1 ) {
109115
return cli.help();
@@ -125,7 +131,12 @@ function main() {
125131
keys = getKeys( flags );
126132
for ( i = 0; i < keys.length; i++ ) {
127133
key = keys[ i ];
128-
if ( key === 'h' || key === 'help' || key === 'V' || key === 'version' ) { // eslint-disable-line max-len
134+
if (
135+
key === 'h' ||
136+
key === 'help' ||
137+
key === 'V' ||
138+
key === 'version'
139+
) {
129140
continue;
130141
}
131142
subargs.push( '--'+keys[ i ]+'='+flags[ keys[ i ] ] );

0 commit comments

Comments
 (0)