diff --git a/doc/cli.markdown b/doc/cli.markdown index ceab091b..27c79ca3 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -607,13 +607,14 @@ produce verbose output ## env rm ID -Remove an environment variable from an application or device, as selected -by command-line options. +Remove a configuration or environment variable from an application or device, +as selected by command-line options. Note that this command asks for confirmation interactively. You can avoid this by passing the `--yes` boolean option. The --device option selects a device instead of an application. +The --config option selects a config var instead of an env var. Service-specific variables are not currently supported. The following examples remove variables that apply to all services in an app or device. @@ -622,7 +623,9 @@ Examples: $ balena env rm 215 $ balena env rm 215 --yes + $ balena env rm 215 --config $ balena env rm 215 --device + $ balena env rm 215 --device --config ### Arguments @@ -636,6 +639,10 @@ environment variable numeric database ID Selects a device environment variable instead of an application environment variable +#### -c, --config + +Selects a configuration variable instead of an environment variable + #### -y, --yes Run in non-interactive mode diff --git a/lib/actions-oclif/env/rm.ts b/lib/actions-oclif/env/rm.ts index 8236f920..bb5a4da4 100644 --- a/lib/actions-oclif/env/rm.ts +++ b/lib/actions-oclif/env/rm.ts @@ -21,6 +21,7 @@ import { stripIndent } from 'common-tags'; import { CommandHelp } from '../../utils/oclif-utils'; interface FlagsDef { + config: boolean; device: boolean; yes: boolean; } @@ -33,13 +34,14 @@ export default class EnvRmCmd extends Command { public static description = stripIndent` Remove an environment variable from an application or device. - Remove an environment variable from an application or device, as selected - by command-line options. + Remove a configuration or environment variable from an application or device, + as selected by command-line options. Note that this command asks for confirmation interactively. You can avoid this by passing the \`--yes\` boolean option. The --device option selects a device instead of an application. + The --config option selects a config var instead of an env var. Service-specific variables are not currently supported. The following examples remove variables that apply to all services in an app or device. @@ -47,7 +49,9 @@ export default class EnvRmCmd extends Command { public static examples = [ '$ balena env rm 215', '$ balena env rm 215 --yes', + '$ balena env rm 215 --config', '$ balena env rm 215 --device', + '$ balena env rm 215 --device --config', ]; public static args = [ @@ -69,6 +73,12 @@ export default class EnvRmCmd extends Command { 'Selects a device environment variable instead of an application environment variable', default: false, }), + config: flags.boolean({ + char: 'c', + description: + 'Selects a configuration variable instead of an environment variable', + default: false, + }), yes: flags.boolean({ char: 'y', description: 'Run in non-interactive mode', @@ -103,7 +113,11 @@ export default class EnvRmCmd extends Command { await balena.pine.delete({ resource: options.device - ? 'device_environment_variable' + ? options.config + ? 'device_config_variable' + : 'device_environment_variable' + : options.config + ? 'application_config_variable' : 'application_environment_variable', id: params.id, });