-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add new flag support for config commands to force profile input flag #272
Changes from 5 commits
4f19291
089ad8b
ea398be
dd55719
fc1008f
87b0d23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
const { TwilioCliError } = require('@twilio/cli-core/src/services/error'); | ||
const { BaseCommand } = require('@twilio/cli-core').baseCommands; | ||
const { flags } = require('@oclif/command'); | ||
const { camelCase } = require('@twilio/cli-core').services.namingConventions; | ||
|
||
const { availableConfigs, getFromEnvironment } = require('../../services/config-utility'); | ||
|
||
|
@@ -10,15 +11,16 @@ class ConfigSet extends BaseCommand { | |
let isError = true; | ||
let isUserConfigUpdated = false; | ||
for (const flag of availableConfigs) { | ||
const configProperty = camelCase(flag); | ||
if (this.flags[flag] !== undefined) { | ||
isError = false; | ||
this.preWarnings(flag); | ||
if (this.flags[flag] === '') { | ||
isUserConfigUpdated = await this.removeConfig(flag, isUserConfigUpdated); | ||
continue; | ||
} | ||
if (await this.isOverwrite(flag)) { | ||
this.userConfig[flag] = this.userConfig.sanitize(this.flags[flag]); | ||
if (await this.isOverwrite(configProperty)) { | ||
this.userConfig[configProperty] = this.sanitizeFlag(this.flags[flag]); | ||
isUserConfigUpdated = true; | ||
} | ||
} | ||
|
@@ -33,6 +35,10 @@ class ConfigSet extends BaseCommand { | |
} | ||
} | ||
|
||
sanitizeFlag(flag) { | ||
return typeof flag === 'string' ? this.userConfig.sanitize(flag) : flag; | ||
} | ||
|
||
Comment on lines
+38
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🆙 |
||
preWarnings(flag) { | ||
const flagEnvValue = getFromEnvironment(flag); | ||
if (flagEnvValue) { | ||
|
@@ -84,6 +90,10 @@ ConfigSet.flags = { | |
char: 'e', | ||
description: 'Sets an Edge configuration.', | ||
}), | ||
'require-profile-input': flags.boolean({ | ||
description: 'Whether the profile flag for Twilio CLI commands is required or not.', | ||
allowNo: true, | ||
}), | ||
Comment on lines
+93
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Q] Do we require default to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would change the functionality for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, makes sense. :) |
||
...BaseCommand.flags, // To add the same flags as BaseCommand | ||
}; | ||
module.exports = ConfigSet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇