Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add init command #12

Merged
merged 3 commits into from
Feb 22, 2024
Merged

feat: add init command #12

merged 3 commits into from
Feb 22, 2024

Conversation

Q1w1N
Copy link
Contributor

@Q1w1N Q1w1N commented Feb 21, 2024

Adding new init command

Summary

init command can be triggered manually, and it triggers automatically if prompt i run withour config file.

Test plan

Run through all use cases.

@Q1w1N Q1w1N requested a review from mdjastrzebski February 21, 2024 12:42
@@ -48,7 +49,13 @@ export const command: CommandModule<{}, PromptOptions> = {
default: false,
describe: 'Verbose output',
}),
handler: (args) => run(args._.join(' '), args),
handler: (args) => {
Copy link
Member

@mdjastrzebski mdjastrzebski Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[high] Instead of trying to handle it here, you should modify bin.ts to include init command as well.

},
{
type: 'confirm',
message: 'Do you already have OpenAI API key?',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are asking about OpenAI api key, what about case when user wanted to provide only Perplexity key?

{
type: (prev) => (prev ? 'password' : null),
name: 'apiKey',
message: 'Paste your OpenAI key here:',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto Perplexity key.

Copy link
Member

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks promising. I've noticed some issue to be handled:

  1. Prompt always ask for OpenAI key (message is fixed to OpenAI)
  2. init command should be configured on bin.ts level, not inside prompt.ts
  3. We currently have ~.airc file which is a JSON file but without .json extension editors might not recognize it as such.

In order to mitigate it for early adopters, let's a a simple code that runs early and moves ~.airc.json file to ~/.airc.json

const LEGACY_CONFIG_FILE = `.airc`;
const CONFIG_FILE = `.airc.json`;

src/config-file.ts Outdated Show resolved Hide resolved
Copy link
Member

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Pls resolve comments before merging @Q1w1N.

@Q1w1N Q1w1N linked an issue Feb 22, 2024 that may be closed by this pull request
@Q1w1N Q1w1N merged commit 83df15c into main Feb 22, 2024
3 checks passed
@Q1w1N Q1w1N deleted the init-command branch February 22, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: init command
2 participants