From fbaac090a16c1410891b899267d26f594b2ac866 Mon Sep 17 00:00:00 2001 From: Atsushi Ishida Date: Sat, 10 Dec 2022 15:13:18 +0900 Subject: [PATCH] chat app --- README.md | 77 +++++++++++++++++++++++++++++++------ src/commands/chat.ts | 18 +++++++++ src/commands/hello/index.ts | 2 +- test/commands/chat.test.ts | 17 ++++++++ 4 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 src/commands/chat.ts create mode 100644 test/commands/chat.test.ts diff --git a/README.md b/README.md index 4c46e7c..eb34a61 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,6 @@ You can ask OpenAI about anything... * [Usage](#usage) * [Commands](#commands) - - - # Usage @@ -31,6 +28,9 @@ USAGE # Commands +* [`telmie chat MESSAGE`](#telmie-chat-message) +* [`telmie hello PERSON`](#telmie-hello-person) +* [`telmie hello world`](#telmie-hello-world) * [`telmie help [COMMAND]`](#telmie-help-command) * [`telmie plugins`](#telmie-plugins) * [`telmie plugins:install PLUGIN...`](#telmie-pluginsinstall-plugin) @@ -42,6 +42,66 @@ USAGE * [`telmie plugins:uninstall PLUGIN...`](#telmie-pluginsuninstall-plugin-2) * [`telmie plugins update`](#telmie-plugins-update) +## `telmie chat MESSAGE` + +You can ask ChatGPT about anything with this cli command. + +``` +USAGE + $ telmie chat [MESSAGE] + +ARGUMENTS + MESSAGE description that you want to ask ChatGPT + +DESCRIPTION + You can ask ChatGPT about anything with this cli command. + +EXAMPLES + $ telmie chat "something to ask" +``` + +_See code: [dist/commands/chat.ts](https://github.com/diveintohacking/telmie/blob/v0.0.1/dist/commands/chat.ts)_ + +## `telmie hello PERSON` + +Say hello + +``` +USAGE + $ telmie hello [PERSON] -f + +ARGUMENTS + PERSON Person to say hello to + +FLAGS + -f, --from= (required) Who is saying hello + +DESCRIPTION + Say hello + +EXAMPLES + $ telmie hello friend --from oclif + hello friend from oclif! (./src/commands/hello/index.ts) +``` + +_See code: [dist/commands/hello/index.ts](https://github.com/diveintohacking/telmie/blob/v0.0.1/dist/commands/hello/index.ts)_ + +## `telmie hello world` + +Say hello world + +``` +USAGE + $ telmie hello world + +DESCRIPTION + Say hello world + +EXAMPLES + $ telmie hello world + hello world! (./src/commands/hello/world.ts) +``` + ## `telmie help [COMMAND]` Display help for telmie. @@ -104,9 +164,7 @@ DESCRIPTION Installation of a user-installed plugin will override a core plugin. - e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command - will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in - the CLI without the need to patch and update the whole CLI. + e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in the CLI without the need to patch and update the whole CLI. ALIASES @@ -164,9 +222,7 @@ DESCRIPTION Installation of a user-installed plugin will override a core plugin. - e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command - will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in - the CLI without the need to patch and update the whole CLI. + e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in the CLI without the need to patch and update the whole CLI. ALIASES @@ -199,8 +255,7 @@ DESCRIPTION Links a plugin into the CLI for development. Installation of a linked plugin will override a user-installed or core plugin. - e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello' - command will override the user-installed or core plugin implementation. This is useful for development work. + e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello' command will override the user-installed or core plugin implementation. This is useful for development work. EXAMPLES diff --git a/src/commands/chat.ts b/src/commands/chat.ts new file mode 100644 index 0000000..6872974 --- /dev/null +++ b/src/commands/chat.ts @@ -0,0 +1,18 @@ +import {Command, Flags} from '@oclif/core' + +export default class Chat extends Command { + static description = 'You can ask ChatGPT about anything with this cli command.' + + static examples = [ + `<%= config.bin %> <%= command.id %> "something to ask"`, + ] + + static flags = {} + + static args = [{name: 'message', description: 'description that you want to ask ChatGPT', required: true}] + + public async run(): Promise { + const {args, flags} = await this.parse(Chat) + const message = args.message + } +} diff --git a/src/commands/hello/index.ts b/src/commands/hello/index.ts index dc71f03..72cdc6c 100644 --- a/src/commands/hello/index.ts +++ b/src/commands/hello/index.ts @@ -4,7 +4,7 @@ export default class Hello extends Command { static description = 'Say hello' static examples = [ - `$ oex hello friend --from oclif + `$ telmie hello friend --from oclif hello friend from oclif! (./src/commands/hello/index.ts) `, ] diff --git a/test/commands/chat.test.ts b/test/commands/chat.test.ts new file mode 100644 index 0000000..6281e6e --- /dev/null +++ b/test/commands/chat.test.ts @@ -0,0 +1,17 @@ +import {expect, test} from '@oclif/test' + +describe('chat', () => { + test + .stdout() + .command(['chat']) + .it('runs hello', ctx => { + expect(ctx.stdout).to.contain('hello world') + }) + + test + .stdout() + .command(['chat', '--name', 'jeff']) + .it('runs hello --name jeff', ctx => { + expect(ctx.stdout).to.contain('hello jeff') + }) +})