diff --git a/src/base-commands/base-command.js b/src/base-commands/base-command.js index 334c9c7e..8332d3d3 100644 --- a/src/base-commands/base-command.js +++ b/src/base-commands/base-command.js @@ -100,6 +100,11 @@ class BaseCommand extends Command { return limitedData; } + + getPromptMessage(message) { + // Drop the trailing period and put a colon at the end of the message. + return message.trim().replace(/[.:]?$/, ':'); + } } BaseCommand.flags = { diff --git a/test/base-commands/base-command.test.js b/test/base-commands/base-command.test.js index c040e5a0..bf9fd424 100644 --- a/test/base-commands/base-command.test.js +++ b/test/base-commands/base-command.test.js @@ -121,5 +121,13 @@ describe('base-commands', () => { expect(ctx.stdout).to.contain('FOO\tBAR\nfoo\tbar\n2\t2'); }); }); + + describe('getPromptMessage', () => { + baseCommandTest.it('adds a colon to the end of the message', ctx => { + expect(ctx.testCmd.getPromptMessage('Name: ')).to.equal('Name:'); + expect(ctx.testCmd.getPromptMessage('Number.')).to.equal('Number:'); + expect(ctx.testCmd.getPromptMessage(' Address ')).to.equal('Address:'); + }); + }); }); });