Skip to content

Commit 755339a

Browse files
chore: change the implementation of new command (#1649)
Co-authored-by: Moderator <60972989+AayushSaini101@users.noreply.github.com>%0ACo-authored-by: asyncapi-bot <bot+chan@asyncapi.io>
1 parent 9a5af55 commit 755339a

File tree

4 files changed

+18
-59
lines changed

4 files changed

+18
-59
lines changed

.changeset/cuddly-files-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@asyncapi/cli": patch
3+
---
4+
5+
feat: change the implementation of new command

docs/usage.md

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -537,58 +537,15 @@ _See code: [src/commands/generate/models.ts](https://github.com/asyncapi/cli/blo
537537

538538
## `asyncapi new`
539539

540-
Creates a new asyncapi file
540+
Create a new AsyncAPI project, specification files, or templates for clients and applications.
541541

542542
```
543543
USAGE
544-
$ asyncapi new [-h] [-n <value>] [-e <value>] [-s] [-p <value>] [--no-tty]
545-
546-
FLAGS
547-
-e, --example=<value>
548-
name of the example to use. Available examples are:
549-
- simple-asyncapi.yml
550-
- adeo-kafka-request-reply-asyncapi.yml
551-
- anyof-asyncapi.yml
552-
- application-headers-asyncapi.yml
553-
- correlation-id-asyncapi.yml
554-
- websocket-gemini-asyncapi.yml
555-
- gitter-streaming-asyncapi.yml
556-
- kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml
557-
- kraken-websocket-request-reply-multiple-channels-asyncapi.yml
558-
- mercure-asyncapi.yml
559-
- not-asyncapi.yml
560-
- operation-security-asyncapi.yml
561-
- oneof-asyncapi.yml
562-
- rpc-client-asyncapi.yml
563-
- rpc-server-asyncapi.yml
564-
- slack-rtm-asyncapi.yml
565-
- tutorial.yml
566-
- streetlights-kafka-asyncapi.yml
567-
- streetlights-operation-security-asyncapi.yml
568-
- streetlights-mqtt-asyncapi.yml
569-
570-
-h, --help
571-
Show CLI help.
572-
573-
-n, --file-name=<value>
574-
name of the file
575-
576-
-p, --port=<value>
577-
port in which to start Studio
578-
579-
-s, --studio
580-
open in Studio
581-
582-
--no-tty
583-
do not use an interactive terminal
544+
$ asyncapi new
584545
585546
DESCRIPTION
586-
Creates a new asyncapi file
587-
588-
EXAMPLES
589-
$ asyncapi new - start creation of a file in interactive mode
547+
Create a new AsyncAPI project, specification files, or templates for clients and applications.
590548
591-
$ asyncapi new --file-name=my-asyncapi.yaml --example=default-example.yaml --no-tty - create a new file with a specific name, using one of the examples and without interactive mode
592549
```
593550

594551
_See code: [src/commands/new/index.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/new/index.ts)_

src/commands/new/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
import File from './file';
1+
import Command from '../../core/base';
2+
import { Help } from '@oclif/core';
23

3-
export default class New extends File {}
4+
export default class New extends Command {
5+
static readonly description = 'Create a new AsyncAPI project, specification files, or templates for clients and applications.';
6+
async run() {
7+
const help = new Help(this.config);
8+
help.showHelp(['new', '--help']);
9+
}
10+
}

test/integration/new/file.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,12 @@ describe('new', () => {
1414
}
1515
}
1616
});
17-
17+
1818
describe('create new file', () => {
1919
afterEach(() => {
2020
testHelper.deleteSpecFileAtWorkingDir();
2121
});
2222

23-
test
24-
.stderr()
25-
.stdout()
26-
.command(['new', '--no-tty', '-n=specification.yaml'])
27-
.it('runs new command', async (ctx,done) => {
28-
expect(ctx.stderr).to.equal('');
29-
expect(ctx.stdout).to.equal('The specification.yaml has been successfully created.\n');
30-
done();
31-
});
32-
3323
test
3424
.stderr()
3525
.stdout()

0 commit comments

Comments
 (0)