@adinsure-ops/ops-cli
Version:
Operations CLI for working with AdInsure
43 lines (42 loc) • 1.62 kB
JavaScript
import { __awaiter } from "tslib";
import { Args } from '@oclif/core';
import CommandBase from '../../command.base.js';
import chalk from 'chalk';
import OpsConfig from '../../lib/config.js';
class ConfigUnset extends CommandBase {
run() {
const _super = Object.create(null, {
run: { get: () => super.run }
});
return __awaiter(this, void 0, void 0, function* () {
_super.run.call(this);
const { args } = yield this.parse(ConfigUnset);
const configPath = this.security.getConfigPath();
const config = new OpsConfig(configPath);
// Check if the key is set; if not, inform the user.
if (config.get(args.type) === undefined) {
this.log(chalk.yellow(`Configuration '${args.type}' is not set.`));
return;
}
// Remove the configuration key and save the file
config.unset(args.type);
config.save();
this.log(chalk.green(`Configuration '${args.type}' has been removed. System defaults will be used.`));
});
}
}
ConfigUnset.aliases = ['config:unset'];
ConfigUnset.description = 'Remove a configuration value so that the system default is used';
ConfigUnset.usage = 'config:unset <type>';
ConfigUnset.examples = [
'$ ops config:unset endpoint',
'$ ops config:unset download_folder'
];
ConfigUnset.args = {
type: Args.string({
description: 'Type of OPS configuration to remove',
options: ['endpoint', 'download_folder'],
required: true,
}),
};
export default ConfigUnset;