@liara/cli
Version:
The command line interface for Liara
41 lines (40 loc) • 1.38 kB
JavaScript
import Command from '../../base.js';
import { Flags } from '@oclif/core';
import { createDebugLogger } from '../../utils/output.js';
class AppStart extends Command {
async run() {
const { flags } = await this.parse(AppStart);
const debug = createDebugLogger(flags.debug);
await this.setGotConfig(flags);
const app = flags.app || (await this.promptProject());
try {
await this.got.post(`v1/projects/${app}/actions/scale`, {
json: { scale: 1 },
});
this.log(`App ${app} started.`);
}
catch (error) {
debug(error.message);
if (error.response && error.response.data) {
debug(JSON.stringify(error.response.data));
}
if (error.response && error.response.status === 404) {
this.error(`Could not find the app.`);
}
if (error.response && error.response.status === 409) {
this.error(`Another operation is already running. Please wait.`);
}
this.error(`Could not start the app. Please try again.`);
}
}
}
AppStart.description = 'start an app';
AppStart.flags = {
...Command.flags,
app: Flags.string({
char: 'a',
description: 'app id',
}),
};
AppStart.aliases = ['start'];
export default AppStart;