File tree Expand file tree Collapse file tree 2 files changed +44
-4
lines changed Expand file tree Collapse file tree 2 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,15 @@ const HelpCommand = Command.extend({
10
10
description : 'Shows help for the CLI.' ,
11
11
works : 'everywhere' ,
12
12
13
- availableOptions : [ ] ,
13
+ availableOptions : [
14
+ {
15
+ name : 'short' ,
16
+ type : Boolean ,
17
+ default : false ,
18
+ aliases : [ 's' ] ,
19
+ description : 'Display command name and description only.'
20
+ } ,
21
+ ] ,
14
22
15
23
anonymousOptions : [ 'command-name (Default: all)' ] ,
16
24
@@ -56,14 +64,20 @@ const HelpCommand = Command.extend({
56
64
}
57
65
58
66
if ( cmd === commandInput ) {
59
- if ( command . printDetailedHelp ( commandOptions ) ) {
67
+ if ( commandOptions . short ) {
68
+ this . ui . writeLine ( command . printShortHelp ( commandOptions ) ) ;
69
+ } else if ( command . printDetailedHelp ( commandOptions ) ) {
60
70
this . ui . writeLine ( command . printDetailedHelp ( commandOptions ) ) ;
61
71
} else {
62
72
this . ui . writeLine ( command . printBasicHelp ( commandOptions ) ) ;
63
73
}
64
74
}
65
75
} else {
66
- this . ui . writeLine ( command . printBasicHelp ( commandOptions ) ) ;
76
+ if ( commandOptions . short ) {
77
+ this . ui . writeLine ( command . printShortHelp ( commandOptions ) ) ;
78
+ } else {
79
+ this . ui . writeLine ( command . printBasicHelp ( commandOptions ) ) ;
80
+ }
67
81
}
68
82
69
83
} ) ;
Original file line number Diff line number Diff line change @@ -550,6 +550,32 @@ let Command = CoreObject.extend({
550
550
551
551
_printCommand : printCommand ,
552
552
553
+ /**
554
+ Prints short help for the command.
555
+ Short help looks like this:
556
+ ng generate <blueprint> <options...>
557
+ Generates new code from blueprints
558
+ aliases: g
559
+ The default implementation is designed to cover all bases
560
+ but may be overridden if necessary.
561
+ @method printShortHelp
562
+ */
563
+ printShortHelp ( ) {
564
+ // ng command-name
565
+ let output ;
566
+ if ( this . isRoot ) {
567
+ output = `Usage: ${ this . name } ` ;
568
+ } else {
569
+ output = `ng ${ this . name } ` ;
570
+ }
571
+
572
+ output += EOL ;
573
+ output += ` ${ this . description } ` ;
574
+ output += EOL ;
575
+
576
+ return output ;
577
+ } ,
578
+
553
579
/**
554
580
Prints basic help for the command.
555
581
Basic help looks like this:
@@ -559,7 +585,7 @@ let Command = CoreObject.extend({
559
585
--dry-run (Default: false)
560
586
--verbose (Default: false)
561
587
The default implementation is designed to cover all bases
562
- but may be overriden if necessary.
588
+ but may be overridden if necessary.
563
589
@method printBasicHelp
564
590
*/
565
591
printBasicHelp ( ) {
You can’t perform that action at this time.
0 commit comments