Skip to content

Commit

Permalink
feat:make asyncapi start studio consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
lmalkam committed Jan 15, 2025
1 parent 639dcab commit 07771a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
26 changes: 22 additions & 4 deletions src/commands/start/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@ import Command from '../../core/base';
import { start as startStudio } from '../../core/models/Studio';
import { load } from '../../core/models/SpecificationFile';
import { studioFlags } from '../../core/flags/start/studio.flags';
import { Args } from '@oclif/core';
import { ValidationError } from '../../core/errors/validation-error';

export default class StartStudio extends Command {
static description = 'starts a new local instance of Studio';

static flags = studioFlags();

static readonly args = {
'spec-file': Args.string({
description: 'spec path, url, or context-name',
required: true,
}),
};

async run() {
const { flags } = await this.parse(StartStudio);
const filePath = flags.file || (await load()).getFilePath();
const { args, flags } = await this.parse(StartStudio);
const filePath = args['spec-file'];
const port = flags.port;

this.specFile = await load(filePath);

try {
this.specFile = await load(filePath);
} catch (err) {
this.error(
new ValidationError({
type: 'invalid-file',
filepath: filePath,
}),
);
}
this.metricsMetadata.port = port;

startStudio(filePath as string, port);
Expand Down
1 change: 0 additions & 1 deletion src/core/flags/start/studio.flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Flags } from '@oclif/core';
export const studioFlags = () => {
return {
help: Flags.help({ char: 'h' }),
file: Flags.string({ char: 'f', description: 'path to the AsyncAPI file to link with Studio' }),
port: Flags.integer({ char: 'p', description: 'port in which to start Studio' }),
};
};

0 comments on commit 07771a6

Please sign in to comment.