/
env.ts
34 lines (25 loc) · 1.01 KB
/
env.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {Command, flags} from '@oclif/command'
import { BlipConf, DockerMachine } from '@lime.it/blip-core'
import { CLIError } from '@oclif/errors';
import { machineNameArg } from '../arguments';
export default class Env extends Command {
static description = 'Prints the docker-machine env for the workspace given machine.'
static flags = {
help: flags.help({char: 'h'}),
shell: flags.string({default: 'bash', description: 'Command output destination shell type.'}),
}
static args = [
machineNameArg
]
async run() {
const {args, flags} = this.parse(Env)
const workspace = await BlipConf.readWorkspace();
if(Object.keys(workspace.machines).length == 0)
throw new CLIError("The workspace do not have any machine");
if(!args.machine)
args.machine = Object.keys(workspace.machines)[0];
if(!workspace.machines[args.machine])
throw new CLIError(`Unknown machine '${args.machine}'`);
process.stdout.write(await DockerMachine.envStdout(args.machine, flags.shell));
}
}