File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -471,6 +471,9 @@ export default class Command<Opt, Arg> {
471
471
*/
472
472
helpText ( ) : string {
473
473
let result = "" ;
474
+ if ( this . _description ) {
475
+ result += this . _description + "\n\n" ;
476
+ }
474
477
// usage part
475
478
result += " Usage: " ;
476
479
if ( this . _usage != null ) {
Original file line number Diff line number Diff line change @@ -129,4 +129,23 @@ describe("Command", () => {
129
129
assert ( cmd . _rest [ 1 ] === "piyo.json" ) ;
130
130
} ) ;
131
131
} ) ;
132
+ describe ( "#helpText" , ( ) => {
133
+ it ( "construct humanreadable text" , ( ) => {
134
+ let cmd = new Command ( "test" ) ;
135
+ cmd . description ( "this is command description" ) ;
136
+ cmd . option ( "-r, --replace [file]" ) ;
137
+
138
+ let text = cmd . helpText ( ) . trim ( ) ;
139
+ let expect = `
140
+ this is command description
141
+
142
+ Usage: test [options]
143
+
144
+ Options:
145
+
146
+ -r, --replace [file]
147
+ ` . trim ( ) ;
148
+ assert ( text === expect ) ;
149
+ } ) ;
150
+ } ) ;
132
151
} ) ;
You can’t perform that action at this time.
0 commit comments