@enspirit/emb
Version:
A replacement for our Makefile-for-monorepos
42 lines (41 loc) • 1.37 kB
JavaScript
import { Args, Flags } from '@oclif/core';
import { BaseCommand, getContext } from '../../index.js';
import { ComposeExecShellOperation } from '../../../docker/index.js';
import { ShellExitError } from '../../../errors.js';
export default class ComponentShellCommand extends BaseCommand {
static aliases = ['shell'];
static description = 'Get a shell on a running component.';
static enableJsonFlag = false;
static examples = ['<%= config.bin %> <%= command.id %>'];
static flags = {
shell: Flags.string({
name: 'shell',
char: 's',
description: 'The shell to run',
default: 'bash',
}),
};
static args = {
component: Args.string({
name: 'component',
description: 'The component you want to get a shell on',
required: true,
}),
};
async run() {
const { flags, args } = await this.parse(ComponentShellCommand);
const { monorepo } = await getContext();
try {
await monorepo.run(new ComposeExecShellOperation(), {
service: args.component,
shell: flags.shell,
});
}
catch (error) {
if (error instanceof ShellExitError) {
this.error(error);
}
throw error;
}
}
}