Skip to content

Commit 5e5b7fb

Browse files
committed
feat(commandpost): show root description to help text fixes #4
1 parent 2bf35d7 commit 5e5b7fb

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/command.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ export default class Command<Opt, Arg> {
471471
*/
472472
helpText(): string {
473473
let result = "";
474+
if (this._description) {
475+
result += this._description + "\n\n";
476+
}
474477
// usage part
475478
result += " Usage: ";
476479
if (this._usage != null) {

test/commandSpec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,23 @@ describe("Command", () => {
129129
assert(cmd._rest[1] === "piyo.json");
130130
});
131131
});
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+
});
132151
});

0 commit comments

Comments
 (0)