-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional summary for short form of subcommand description. (#1726)
For backwards compatibility, the description is used for the subcommand listing if the summary is missing. So by default there is no change in existing programs.
- Loading branch information
1 parent
d660967
commit cc2db5b
Showing
8 changed files
with
97 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const commander = require('../'); | ||
|
||
test('when set summary then get summary', () => { | ||
const program = new commander.Command(); | ||
const summary = 'abcdef'; | ||
program.summary(summary); | ||
expect(program.summary()).toMatch(summary); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const commander = require('../'); | ||
|
||
// These are tests of the Help class, not of the Command help. | ||
// There is some overlap with the higher level Command tests (which predate Help). | ||
|
||
describe('subcommandDescription', () => { | ||
test('when program has no summary or description then empty string', () => { | ||
const program = new commander.Command(); | ||
const helper = new commander.Help(); | ||
expect(helper.subcommandDescription(program)).toEqual(''); | ||
}); | ||
|
||
test('when program has summary then return summary', () => { | ||
const summary = 'summary'; | ||
const program = new commander.Command(); | ||
program.summary(summary); | ||
const helper = new commander.Help(); | ||
expect(helper.subcommandDescription(program)).toEqual(summary); | ||
}); | ||
|
||
test('when program has description then return description', () => { | ||
const description = 'description'; | ||
const program = new commander.Command(); | ||
program.description(description); | ||
const helper = new commander.Help(); | ||
expect(helper.subcommandDescription(program)).toEqual(description); | ||
}); | ||
|
||
test('when program has summary and description then return summary', () => { | ||
const summary = 'summary'; | ||
const program = new commander.Command(); | ||
program.summary(summary); | ||
program.description('description'); | ||
const helper = new commander.Help(); | ||
expect(helper.subcommandDescription(program)).toEqual(summary); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters