File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,9 +4,23 @@ import BigText from 'ink-big-text';
44import Gradient from 'ink-gradient' ;
55import info from './utils/info.js' ;
66import askForCommitMessage from './utils/commit.js' ;
7+ import { getOpenAIKey , setOpenAIKey , deleteOPenAIKey } from './utils/api.js' ;
78
8- export default function App ( ) {
9- askForCommitMessage ( ) ;
9+ export default function App ( { flags} ) {
10+ if ( flags . setopenai ) {
11+ setOpenAIKey ( flags . setopenai ) ;
12+ }
13+ if ( flags . delopenai ) {
14+ deleteOPenAIKey ( ) ;
15+ }
16+ if ( ! getOpenAIKey ( ) ) {
17+ console . log ( 'Please provide an OpenAI API key.' ) ;
18+ console . log ( 'You can get one from https://platform.openai.com/account/api-keys' )
19+ console . log ( 'Run `magicc --setopenai=<api-key>` to save your API key and try again.' ) ;
20+ } else {
21+ console . log ( 'You have an OpenAI API key, you can now generate a commit message.' ) ;
22+ askForCommitMessage ( ) ;
23+ }
1024 return (
1125 < >
1226 < Gradient name = 'passion' >
You can’t perform that action at this time.
0 commit comments