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

add greeting command #30

Merged
merged 2 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cmd/greeting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"github.com/JunNishimura/Chatify/ui"
tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
)

func NewGreetingCommand() *cobra.Command {
return &cobra.Command{
Use: "greeting",
Short: "config setting for Chatify",
Long: "config setting for Chatify",
RunE: func(cmd *cobra.Command, args []string) error {
p := tea.NewProgram(ui.NewModel(), tea.WithAltScreen())

if _, err := p.Run(); err != nil {
return err
}

return nil
},
}
}
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ func main() {

// check if token viper is set
if !isClientInfoSet() {
if err := askClientInfo(); err != nil {
log.Fatal(err)
}

authorize()
} else {
ctx := context.Background()
Expand Down Expand Up @@ -80,8 +76,12 @@ func main() {
}

heyCommand := cmd.NewHeyCommand(context.Background(), client, clientViper.GetString(OpenAIApiKeyName))
greetingCommand := cmd.NewGreetingCommand()

rootCmd.AddCommand(heyCommand)
rootCmd.AddCommand(
heyCommand,
greetingCommand,
)

if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
Expand Down