UNPKG

@liara/cli

Version:

The command line interface for Liara

39 lines (38 loc) 1.35 kB
import Command from '../../base.js'; import { Flags } from '@oclif/core'; import { createDebugLogger } from '../../utils/output.js'; class AppRestart extends Command { async run() { const { flags } = await this.parse(AppRestart); 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/restart`); this.log(`App ${app} restarted.`); } 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 restart the app. Please try again.`); } } } AppRestart.description = 'restart an app'; AppRestart.flags = { ...Command.flags, app: Flags.string({ char: 'a', description: 'app id', }), }; AppRestart.aliases = ['restart']; export default AppRestart;