Skip to content

Commit

Permalink
Made studio command consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilDahekar committed Jan 18, 2025
1 parent 5635245 commit eba1126
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions asyncapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
asyncapi: '3.0.0'
info:
title: Welcome to AsyncAPI Studio
version: '1.0.0'
description: This is a sample AsyncAPI document to help you get started. Define your async APIs, channels, messages, and bindings here.
contact:
name: AsyncAPI
url: https://www.asyncapi.com
email: [email protected]
6 changes: 4 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,12 @@ starts a new local instance of Studio

```
USAGE
$ asyncapi start studio [-h] [-f <value>] [-p <value>]
$ asyncapi start studio [SPEC_FILE] [-h] [-p <value>]
ARGUMENTS
SPEC-FILE spec path, url, or context-name
FLAGS
-f, --file=<value> path to the AsyncAPI file to link with Studio
-h, --help Show CLI help.
-p, --port=<value> port in which to start Studio
Expand Down
13 changes: 11 additions & 2 deletions src/commands/start/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@ 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';

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: false}),
};

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'] || (await load()).getFilePath();
const port = flags.port;

if (!args['spec-file']) {
this.log('\nTo open a specific AsyncAPI file in the Studio, use: asyncapi start studio [your-spec-file-location]\n\n');
}

this.specFile = await load(filePath);
this.metricsMetadata.port = 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 eba1126

Please sign in to comment.