Skip to content

Commit 8468619

Browse files
author
childish-sambino
authored
fix: update the wording for the env vars help message (#80)
1 parent b8b003f commit 8468619

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/base-commands/twilio-client-command.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const chalk = require('chalk');
21
const { flags } = require('@oclif/command');
32
const BaseCommand = require('./base-command');
43
const CliRequestClient = require('../services/cli-http-client');
@@ -25,14 +24,14 @@ class TwilioClientCommand extends BaseCommand {
2524
this.currentProfile = this.userConfig.getProfileById(this.flags.profile);
2625

2726
const reportUnconfigured = (verb, message = '') => {
28-
const profileParam = this.flags.profile ? ' -p ' + this.flags.profile : '';
27+
const profileParam = this.flags.profile ? ` --profile "${this.flags.profile}"` : '';
2928
throw new TwilioCliError(
30-
`To ${verb} the profile, run: ` + chalk.whiteBright('twilio profiles:create' + profileParam) + message
29+
`To ${verb} the profile, run:\n\n twilio profiles:create${profileParam}${message}`
3130
);
3231
};
3332

3433
if (!this.currentProfile) {
35-
this.logger.error('No profile configured.');
34+
this.logger.error(`Could not find profile "${this.flags.profile}".`);
3635
reportUnconfigured('create', '\n\n' + HELP_ENVIRONMENT_VARIABLES);
3736
}
3837

src/services/messaging/help-messages.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
const { CLI_NAME } = require('../config');
22

3-
exports.HELP_ENVIRONMENT_VARIABLES = `You can also use credentials stored in environment variables:
3+
exports.HELP_ENVIRONMENT_VARIABLES = `Alternatively, ${CLI_NAME} can use credentials stored in environment variables:
44
5-
# OPTION 1 (recommended)
5+
# OPTION 1 (recommended)
66
TWILIO_ACCOUNT_SID = your Account SID from twil.io/console
77
TWILIO_API_KEY = an API Key created at twil.io/get-api-key
88
TWILIO_API_SECRET = the secret for the API Key
99
1010
# OPTION 2
1111
TWILIO_ACCOUNT_SID = your Account SID from twil.io/console
12-
TWILIO_AUTH_TOKEN = your Auth Token from twil.io/console`;
12+
TWILIO_AUTH_TOKEN = your Auth Token from twil.io/console
13+
14+
Once these environment variables are set, a ${CLI_NAME} profile is not required to move forward with installation.`;
1315

1416
exports.UNEXPECTED_ERROR = `${CLI_NAME} encountered an unexpected error. \
1517
To report this issue, execute the command with the "-l debug" flag, then copy the output to a new issue here: \

test/base-commands/twilio-client-command.test.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,18 @@ describe('base-commands', () => {
8181
setUpTest(['-l', 'debug'], { setUpUserConfig: () => 0 })
8282
.exit(1)
8383
.it('should fail for a non-existent active profile', ctx => {
84-
expect(ctx.stderr).to.contain('No profile configured');
85-
expect(ctx.stderr).to.contain('To create the profile, run: twilio profiles:create');
84+
expect(ctx.stderr).to.contain('Could not find profile');
85+
expect(ctx.stderr).to.contain('To create the profile, run:');
86+
expect(ctx.stderr).to.contain('twilio profiles:create');
8687
expect(ctx.stderr).to.contain('TWILIO_ACCOUNT_SID');
8788
});
8889

8990
setUpTest(['-p', 'alt', '-l', 'debug'])
9091
.exit(1)
9192
.it('should fail for a non-existent profile', ctx => {
92-
expect(ctx.stderr).to.contain('No profile configured');
93-
expect(ctx.stderr).to.contain('To create the profile, run: twilio profiles:create -p alt');
93+
expect(ctx.stderr).to.contain('Could not find profile');
94+
expect(ctx.stderr).to.contain('To create the profile, run:');
95+
expect(ctx.stderr).to.contain('twilio profiles:create --profile "alt"');
9496
expect(ctx.stderr).to.contain('TWILIO_ACCOUNT_SID');
9597
});
9698

@@ -105,9 +107,8 @@ describe('base-commands', () => {
105107
.exit(1)
106108
.it('should handle a secure storage error', ctx => {
107109
expect(ctx.stderr).to.contain('Could not get credentials for profile "twilio-cli-unit-testing"');
108-
expect(ctx.stderr).to.contain(
109-
'To reconfigure the profile, run: twilio profiles:create -p twilio-cli-unit-testing'
110-
);
110+
expect(ctx.stderr).to.contain('To reconfigure the profile, run:');
111+
expect(ctx.stderr).to.contain('twilio profiles:create --profile "twilio-cli-unit-testing"');
111112
});
112113

113114
setUpTest([], { commandClass: ThrowingClientCommand })

0 commit comments

Comments
 (0)