@cto.ai/ops
Version:
💻 CTO.ai - The CLI built for Teams 🚀
50 lines (49 loc) • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const base_1 = tslib_1.__importStar(require("./../base"));
const CustomErrors_1 = require("./../errors/CustomErrors");
class Stop extends base_1.default {
constructor() {
super(...arguments);
this.stopOp = async (runId, config) => {
try {
await this.services.api.remove(`/private/teams/${config.team.name}/service/${runId}`, null, {
headers: {
Authorization: this.accessToken,
},
});
}
catch (err) {
this.debug('%0', err);
this.log(this.ux.colors.whiteBright(`❗ Sorry, we encountered an error trying to stop the service ${runId}`));
throw new CustomErrors_1.APIError(err);
}
};
}
async run() {
const config = await this.isLoggedIn();
try {
const parsedArgs = this.parse(Stop);
await this.stopOp(parsedArgs.args.runId, config);
}
catch (err) {
this.debug('%O', err);
this.config.runHook('error', {
err,
accessToken: config.tokens.accessToken,
});
}
}
}
exports.default = Stop;
Stop.description = 'Stop a service, pipeline or command running in The Ops Cloud';
Stop.flags = {
help: base_1.flags.help({ char: 'h' }),
};
Stop.args = [
{
name: 'runId',
description: 'Run ID of the service, pipeline or command to stop',
},
];