Skip to content

Commit

Permalink
chore: change the implementation of new command (#1649)
Browse files Browse the repository at this point in the history
Co-authored-by: Moderator <[email protected]>%0ACo-authored-by: asyncapi-bot <[email protected]>
  • Loading branch information
Adi-204 and asyncapi-bot authored Feb 14, 2025
1 parent 9a5af55 commit 755339a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 59 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-files-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@asyncapi/cli": patch
---

feat: change the implementation of new command
49 changes: 3 additions & 46 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,58 +537,15 @@ _See code: [src/commands/generate/models.ts](https://github.com/asyncapi/cli/blo

## `asyncapi new`

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

```
USAGE
$ asyncapi new [-h] [-n <value>] [-e <value>] [-s] [-p <value>] [--no-tty]
FLAGS
-e, --example=<value>
name of the example to use. Available examples are:
- simple-asyncapi.yml
- adeo-kafka-request-reply-asyncapi.yml
- anyof-asyncapi.yml
- application-headers-asyncapi.yml
- correlation-id-asyncapi.yml
- websocket-gemini-asyncapi.yml
- gitter-streaming-asyncapi.yml
- kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml
- kraken-websocket-request-reply-multiple-channels-asyncapi.yml
- mercure-asyncapi.yml
- not-asyncapi.yml
- operation-security-asyncapi.yml
- oneof-asyncapi.yml
- rpc-client-asyncapi.yml
- rpc-server-asyncapi.yml
- slack-rtm-asyncapi.yml
- tutorial.yml
- streetlights-kafka-asyncapi.yml
- streetlights-operation-security-asyncapi.yml
- streetlights-mqtt-asyncapi.yml
-h, --help
Show CLI help.
-n, --file-name=<value>
name of the file
-p, --port=<value>
port in which to start Studio
-s, --studio
open in Studio
--no-tty
do not use an interactive terminal
$ asyncapi new
DESCRIPTION
Creates a new asyncapi file
EXAMPLES
$ asyncapi new - start creation of a file in interactive mode
Create a new AsyncAPI project, specification files, or templates for clients and applications.
$ 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
```

_See code: [src/commands/new/index.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/new/index.ts)_
Expand Down
11 changes: 9 additions & 2 deletions src/commands/new/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import File from './file';
import Command from '../../core/base';
import { Help } from '@oclif/core';

export default class New extends File {}
export default class New extends Command {
static readonly description = 'Create a new AsyncAPI project, specification files, or templates for clients and applications.';
async run() {
const help = new Help(this.config);
help.showHelp(['new', '--help']);
}
}
12 changes: 1 addition & 11 deletions test/integration/new/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,12 @@ describe('new', () => {
}
}
});

describe('create new file', () => {
afterEach(() => {
testHelper.deleteSpecFileAtWorkingDir();
});

test
.stderr()
.stdout()
.command(['new', '--no-tty', '-n=specification.yaml'])
.it('runs new command', async (ctx,done) => {
expect(ctx.stderr).to.equal('');
expect(ctx.stdout).to.equal('The specification.yaml has been successfully created.\n');
done();
});

test
.stderr()
.stdout()
Expand Down

0 comments on commit 755339a

Please sign in to comment.