Skip to content

Commit

Permalink
refactor(cmd): add context to root command execution
Browse files Browse the repository at this point in the history
  • Loading branch information
tfkhdyt committed Nov 11, 2024
1 parent 38f3497 commit 88a2df5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright © 2024 Taufik Hidayat <tfkhdyt@proton.me>
package cmd

import (
"context"
"fmt"
"os"
"path/filepath"
Expand All @@ -12,26 +13,26 @@ import (
"github.com/spf13/viper"

"github.com/tfkhdyt/geminicommit/cmd/config"
"github.com/tfkhdyt/geminicommit/internal/container"
"github.com/tfkhdyt/geminicommit/internal/delivery/cli/handler"
)

var (
cfgFile string
stageAll bool
userContext string
model string
rootHandler = container.GetRootHandlerInstance()
rootHandler = handler.NewRootHandler()
)

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "geminicommit",
Short: "CLI that writes your git commit messages for you with Google Gemini AI",
Long: "CLI that writes your git commit messages for you with Google Gemini AI",
Version: "0.2.0",
Version: "0.2.1",
// Uncomment the following line if your bare application
// has an action associated with it:
Run: rootHandler.RootCommand(&stageAll, &userContext, &model),
Run: rootHandler.RootCommand(context.Background(), &stageAll, &userContext, &model),
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand All @@ -58,7 +59,7 @@ func init() {
RootCmd.Flags().
StringVarP(&userContext, "context", "c", "", "additional context to be added to the commit message")
RootCmd.Flags().
StringVarP(&model, "model", "m", "gemini-1.5-flash-latest", "google gemini model to use")
StringVarP(&model, "model", "m", "gemini-1.5-pro", "google gemini model to use")
}

// initConfig reads in config file and ENV variables if set.
Expand Down

0 comments on commit 88a2df5

Please sign in to comment.