UNPKG

steadybit

Version:

Command-line interface to interact with the Steadybit API

45 lines 2.07 kB
"use strict"; // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2022 Steadybit GmbH var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.select = select; exports.promptProfileSelection = promptProfileSelection; const inquirer_1 = __importDefault(require("inquirer")); const service_1 = require("./service"); const errors_1 = require("../../errors"); function select() { return __awaiter(this, void 0, void 0, function* () { const activeProfileName = yield promptProfileSelection('Choose the new active profile:'); yield (0, service_1.setActiveProfile)(activeProfileName); }); } function promptProfileSelection(message) { return __awaiter(this, void 0, void 0, function* () { const profiles = yield (0, service_1.getProfiles)(); if (profiles.length === 0) { throw (0, errors_1.abortExecution)('No profiles configured.'); } const { activeProfileName } = yield inquirer_1.default.prompt([ { type: 'list', name: 'activeProfileName', message, choices: profiles.map(p => p.name), }, ]); return activeProfileName; }); } //# sourceMappingURL=select.js.map