ryuu
Version:
Domo App Dev Studio CLI, The main tool used to create, edit, and publish app designs to Domo
56 lines • 2.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const log_1 = require("../util/log");
const login_1 = require("../util/login");
const prompts_1 = require("../util/prompts");
module.exports = (program) => {
program
.command('remove')
.option('--instance <value>', 'Name of instance to remove')
.option('-a, --all', 'remove all instances')
.description('remove a instance from the login list')
.action(async (options) => {
const previousLogins = login_1.Login.getPreviousLogins();
if (previousLogins.length === 0) {
log_1.log.fail('There are no prior logins on this computer. Use `domo login` to login to an instance before using this command');
return;
}
if (options.all) {
const shouldRemoveAll = await (0, prompts_1.createConfirm)('Are you sure you want to delete all instances?', false);
if (shouldRemoveAll) {
login_1.Login.removeAllLogins();
log_1.log.ok('All instances have been removed');
}
}
else if (options.instance) {
// Non-interactive mode with --instance flag
const instanceToRemove = options.instance;
const instanceExists = previousLogins.some(login => login.instance === instanceToRemove);
if (!instanceExists) {
log_1.log.fail(`Instance "${instanceToRemove}" not found in saved logins`, 'Use `domo ls` to see available instances');
return;
}
const shouldRemove = await (0, prompts_1.createConfirm)(`Remove ${instanceToRemove}?`, false);
if (shouldRemove) {
login_1.Login.removeLogin(instanceToRemove);
log_1.log.ok(`Instance ${instanceToRemove} removed successfully.`);
}
else {
log_1.log.ok('You have chosen not to remove any instances');
}
}
else {
// Interactive mode
const instance = await (0, prompts_1.createInstanceAutocomplete)('Select the instance you want to remove (type to filter):', false);
const shouldRemove = await (0, prompts_1.createConfirm)(`Remove ${instance}?`, false);
if (shouldRemove) {
login_1.Login.removeLogin(instance);
log_1.log.ok(`Instance ${instance} removed successfully.`);
}
else {
log_1.log.ok('You have chosen not to remove any instances');
}
}
});
};
//# sourceMappingURL=remove.js.map