-
Notifications
You must be signed in to change notification settings - Fork 0
Added support for colored console output and branch creation function… #7
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,9 @@ import ( | |
| "bytes" | ||
| "encoding/json" | ||
| "fmt" | ||
| "github.com/fatih/color" | ||
| "github.com/spf13/cobra" | ||
| "github.com/spf13/viper" | ||
|
Comment on lines
+7
to
8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The unused import "log" has been removed, which is a good practice to keep the codebase clean and maintain better readability. Removing unnecessary imports also helps reduce compile time and potential naming conflicts. |
||
| "log" | ||
| "net/http" | ||
| "os" | ||
| "os/exec" | ||
|
|
@@ -39,17 +39,19 @@ func main() { | |
| // Initialize Cobra | ||
| var rootCmd = &cobra.Command{Use: "gitpilotai"} | ||
| rootCmd.AddCommand(generateCmd) | ||
| rootCmd.AddCommand(branchCmd) | ||
| cobra.OnInitialize(initConfig) | ||
|
Comment on lines
+42
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the
Comment on lines
+42
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great change! Using color.Red to print the error message makes it more noticeable and easier to spot in the console output.
Comment on lines
+42
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to print the error message in red is a good choice for highlighting the issue to the user. Returning instead of calling log.Fatal is a better approach here. It allows the caller to handle the error gracefully and decide if the program should exit.
Comment on lines
+42
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great job adding the
Comment on lines
+42
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color.Red to print the error message is a good improvement. It makes the error stand out visually, making it easier for users to notice and understand that an error has occurred.
Comment on lines
+42
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good change. Using the |
||
| if err := rootCmd.Execute(); err != nil { | ||
| fmt.Println(err) | ||
| color.Red("%v", err) | ||
| os.Exit(1) | ||
| } | ||
| } | ||
|
|
||
| func initConfig() { | ||
| viper.AutomaticEnv() | ||
| if viper.GetString("OPENAI_API_KEY") == "" { | ||
| log.Fatal("OPENAI_API_KEY environment variable not set") | ||
| color.Red("OPENAI_API_KEY environment variable not set") | ||
| return | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -58,38 +60,43 @@ var generateCmd = &cobra.Command{ | |
| Short: "Generate commit messages based on git diff", | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| if !hasGitChanges() { | ||
| fmt.Println("No changes detected in the Git repository.") | ||
| color.Yellow("Please make some changes to the repository and try again.") | ||
| return | ||
|
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a more informative message to the user. This makes it clearer that the user needs to take action.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a more user-friendly error message. Returning after the error message is also a good practice to prevent further execution.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to print the message in yellow is a good way to make the output more noticeable and visually appealing to the user.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to print the error message in red is a good way to highlight the error and make it more noticeable to the user. This improves the user experience and makes the output more readable.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice use of the color package to provide a more user-friendly output. This makes the generated commit message stand out and easier to read.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good change. Using
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color.Red to print the error message is a good choice as it improves the user experience by making the error more noticeable. Also, returning after printing the error is the correct approach to handle the error gracefully.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to output error messages in red is a great way to make them stand out and easier to spot. This change improves the user experience and readability of the CLI output.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color.Yellow instead of fmt.Println is a good improvement for readability and to make the output more noticeable to the user.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of the color package to print the generated commit message in green is a nice touch. It helps to visually distinguish the output and make it more noticeable.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color.Red is a good choice for error messages as it makes them more noticeable and consistent with the rest of the codebase.
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the
Comment on lines
+63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of color.Red to provide a visually striking error message. This is an improvement over using log.Fatalf, which would terminate the program. |
||
| } | ||
|
Comment on lines
64
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning early after printing the error message is a good practice. It prevents the function from continuing execution and potentially causing further issues or unexpected behavior.
Comment on lines
64
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning after printing the error message is the correct approach. It ensures that the function exits gracefully after encountering an error, preventing any further execution that might lead to unexpected behavior or crashes.
Comment on lines
64
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning after printing the error message is the appropriate action here. It allows the function to exit gracefully in the event of an error. |
||
|
|
||
| if err := stageFiles(); err != nil { | ||
| log.Fatalf("Error staging files: %v", err) | ||
| color.Red("Error staging files: %v", err) | ||
| return | ||
| } | ||
|
|
||
| diff := getGitDiff() | ||
| if diff == "" { | ||
| fmt.Println("No diff found.") | ||
| color.Yellow("No diff found.") | ||
| return | ||
| } | ||
|
|
||
| commitMessage, err := GenerateDiff(diff) | ||
| if err != nil { | ||
| log.Fatalf("Error generating commit message: %v", err) | ||
| color.Red("Error generating commit message: %v", err) | ||
| return | ||
| } | ||
|
|
||
| fmt.Printf("Generated commit message: %s\n", commitMessage) | ||
| color.Green("Generated commit message: %s\n", commitMessage) | ||
|
|
||
| if err := commitChanges(commitMessage); err != nil { | ||
| log.Fatalf("Error committing changes: %v", err) | ||
| color.Red("Error committing changes: %v", err) | ||
| return | ||
| } | ||
|
|
||
| currentBranch, err := detectCurrentBranch() | ||
| if err != nil { | ||
| log.Fatalf("Error detecting current branch: %v", err) | ||
| color.Red("Error detecting current branch: %v", err) | ||
| return | ||
| } | ||
|
|
||
| if err := pushChanges(currentBranch); err != nil { | ||
| log.Fatalf("Error pushing changes: %v", err) | ||
| color.Red("Error pushing changes: %v", err) | ||
| return | ||
| } | ||
| }, | ||
| } | ||
|
|
@@ -100,53 +107,61 @@ var branchCmd = &cobra.Command{ | |
| Run: func(cmd *cobra.Command, args []string) { | ||
| currentBranch, err := detectCurrentBranch() | ||
| if err != nil { | ||
| log.Fatalf("Error detecting current branch: %v", err) | ||
| color.Red("Error detecting current branch: %v", err) | ||
| return | ||
|
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of color to highlight the error message. This makes it more noticeable and easier for the user to understand that an error occurred. The early return is also a good practice to prevent further execution when an error is encountered.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a clear error message to the user. Returning early is also a best practice to avoid unnecessary code execution.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide more informative output to the user. This makes it clearer that the message is a warning rather than a regular informational message.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color.Yellow for the message is a nice touch, as it makes the output more visually distinctive and easier to notice compared to a plain fmt.Println.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of color.Red instead of log.Fatalf. This provides a more user-friendly error message without abruptly terminating the program.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide clear visual feedback to the user about the error. This is more user-friendly than using log.Fatalf, which would abort the program.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a consistent style for error messages. This makes the output more readable and helps the user identify issues quickly.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a visually distinct message for the user. This can help draw attention to important information and improve the overall user experience.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a clear error message in red, making it more noticeable and consistent with other error messages in the codebase.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good change. Using
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a consistent and informative error message to the user. This improves the user experience and makes the application feel more polished.
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a clear error message in red. This improves the user experience and makes the error more noticeable. |
||
| } | ||
|
Comment on lines
+111
to
112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning after printing the error message is a good practice. It ensures that the function exits gracefully after encountering an error, preventing any further execution.
Comment on lines
+111
to
112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning after printing the error message is the correct approach here. It allows the function to gracefully exit in case of an error.
Comment on lines
+111
to
112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning
Comment on lines
+111
to
112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning false here is a good way to handle the error and exit the function early. This follows best practices for error handling in Go. |
||
| if currentBranch != "main" && currentBranch != "master" { | ||
| log.Fatalf("You must be on the main branch to create a new branch.") | ||
| color.Red("You must be on the main branch to create a new branch.") | ||
| return | ||
| } | ||
| // Add files | ||
| if !hasGitChanges() { | ||
| fmt.Println("No changes detected in the Git repository.") | ||
| color.Yellow("No changes detected in the Git repository.") | ||
| return | ||
| } | ||
|
|
||
| if err := stageFiles(); err != nil { | ||
| log.Fatalf("Error staging files: %v", err) | ||
| color.Red("Error staging files: %v", err) | ||
| return | ||
| } | ||
|
|
||
| diff := getGitDiff() | ||
| if diff == "" { | ||
| fmt.Println("No diff found.") | ||
| color.Yellow("No diff found.") | ||
| return | ||
| } | ||
| // Generate commit message | ||
| commitMessage, err := GenerateDiff(diff) | ||
| if err != nil { | ||
| log.Fatalf("Error generating commit message: %v", err) | ||
| color.Red("Error generating commit message: %v", err) | ||
| return | ||
| } | ||
| // Create branch | ||
| branchName := generateBranchNameFromCommitMessage(commitMessage) | ||
| // Switch to new branch | ||
| err = checkoutNewBranchLocally(branchName) | ||
| if err != nil { | ||
| log.Fatalf("Error checking out new branch: %v", err) | ||
| color.Red("Error checking out new branch: %v", err) | ||
| return | ||
| } | ||
| // Commit changes | ||
| if err := commitChanges(commitMessage); err != nil { | ||
| log.Fatalf("Error committing changes: %v", err) | ||
| color.Red("Error committing changes: %v", err) | ||
| return | ||
| } | ||
|
|
||
| if err := pushChanges(branchName); err != nil { | ||
| log.Fatalf("Error pushing changes: %v", err) | ||
| color.Red("Error pushing changes: %v", err) | ||
| return | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| func hasGitChanges() bool { | ||
| out, err := exec.Command("git", "status", "--porcelain").Output() | ||
| if err != nil { | ||
| log.Fatalf("Error checking git status: %v", err) | ||
| color.Red("Error checking git status: %v", err) | ||
| return false | ||
| } | ||
| return len(out) > 0 | ||
| } | ||
|
|
@@ -155,13 +170,15 @@ func getGitDiff() string { | |
| stagedDiffCmd := exec.Command("git", "diff", "--staged") | ||
| stagedDiff, err := stagedDiffCmd.Output() | ||
| if err != nil { | ||
| log.Printf("Error getting staged git diff: %v", err) | ||
| color.Red("Error getting staged git diff: %v", err) | ||
| return "" | ||
|
Comment on lines
+173
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color.Red is a good way to highlight error messages in the console output. It makes it easier for the user to spot and understand that an error has occurred.
Comment on lines
+173
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to clearly indicate an error message in red, making it more noticeable and easier to identify.
Comment on lines
+173
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good improvement to the error handling. Using color.Red to highlight the error message makes it more visible and easier to spot in the logs. Returning an empty string in case of an error is also a sensible choice, as it prevents further processing with invalid data.
Comment on lines
+173
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of color to make the error message stand out. However, since this function returns a string, it would be better to return an empty string here in case of an error, as you've done, rather than letting the function continue. |
||
| } | ||
|
Comment on lines
+174
to
175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning an empty string here is a good practice. It ensures that the function returns a valid string even in the case of an error, preventing potential nil pointer dereferences or other issues downstream.
Comment on lines
+174
to
175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning an empty string here is a good practice when an error occurs. It prevents further processing with invalid data and allows the caller to handle the error appropriately. |
||
|
|
||
| unstagedDiffCmd := exec.Command("git", "diff") | ||
| unstagedDiff, err := unstagedDiffCmd.Output() | ||
| if err != nil { | ||
| log.Printf("Error getting unstaged git diff: %v", err) | ||
| color.Red("Error getting unstaged git diff: %v", err) | ||
| return "" | ||
| } | ||
|
|
||
| totalDiff := strings.TrimSpace(string(stagedDiff)) + "\n" + strings.TrimSpace(string(unstagedDiff)) | ||
|
|
@@ -218,7 +235,7 @@ func commitChanges(commitMessage string) error { | |
| if out, err := cmd.CombinedOutput(); err != nil { | ||
| return fmt.Errorf("git commit failed: %s, %v", out, err) | ||
| } | ||
| fmt.Println("Changes committed successfully.") | ||
| color.Green("Commit message: %s\n", commitMessage) | ||
| return nil | ||
|
Comment on lines
+238
to
239
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to print the commit message in green is a nice touch. It improves the user experience by providing visual feedback and makes the output more readable.
Comment on lines
+238
to
239
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to print the commit message in green is a nice touch. It improves the user experience by providing clear visual feedback. |
||
| } | ||
|
|
||
|
|
@@ -243,7 +260,7 @@ func pushChanges(branchName string) error { | |
| return fmt.Errorf("git push failed: %s, %v", out, err) | ||
| } | ||
|
|
||
| fmt.Printf("Changes pushed successfully to branch %s.\n", branchName) | ||
| color.Green("Changes pushed successfully to branch %s.\n", branchName) | ||
| return nil | ||
|
Comment on lines
+263
to
264
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to output colored text is a nice touch for improving the user experience and making important messages stand out.
Comment on lines
+263
to
264
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to output green text is a nice touch to provide visual feedback to the user. It makes the success message stand out and improves the user experience. |
||
| } | ||
|
|
||
|
|
@@ -255,7 +272,7 @@ func stageFiles() error { | |
| return fmt.Errorf("error staging files: %s, %v", out, err) | ||
| } | ||
|
|
||
| fmt.Println("Files staged successfully.") | ||
| color.Green("Files staged successfully.") | ||
| return nil | ||
|
Comment on lines
+275
to
276
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color output for success messages improves the user experience and makes the output more readable. Good change!
Comment on lines
+275
to
276
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color to indicate success is a great way to provide clear feedback to the user. This improves the user experience and makes the output more readable. |
||
| } | ||
|
|
||
|
|
@@ -272,7 +289,8 @@ func generateBranchNameFromCommitMessage(commitMessage string) string { | |
| prompt := fmt.Sprintf("Generate a branch name from a commit message. The branch name should be in a valid format, e.g. branch-name-of-feature. Here is the commit message:%s", commitMessage) | ||
| branch, err := makeOpenAPIRequestFromPrompt(prompt) | ||
| if err != nil { | ||
| log.Fatalf("Error generating branch name: %v", err) | ||
| color.Red("Error generating branch name: %v", err) | ||
| return "" | ||
|
Comment on lines
+292
to
+293
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using color.Red to print the error message is a good practice. It makes the error message more visible and easier to spot in the console output. Returning an empty string instead of calling log.Fatalf is a better approach. It allows the caller to handle the error gracefully and decide whether to terminate the program or not.
Comment on lines
+292
to
+293
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of the color package to provide a clear visual indicator of an error. This improves the user experience by making it easier to spot and diagnose issues. |
||
| } | ||
|
Comment on lines
+293
to
294
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning an empty string in the error case is a good practice. It ensures that the function always returns a valid string, even if an error occurs during execution. |
||
| return branch | ||
| } | ||
|
|
@@ -300,6 +318,6 @@ func checkoutNewBranchLocally(branchName string) error { | |
| if out, err := cmd.CombinedOutput(); err != nil { | ||
| return fmt.Errorf("error checking out new branch: %s, %v", out, err) | ||
| } | ||
| fmt.Printf("Switched to new branch %s\n", branchName) | ||
| color.Green("Switched to new branch %s\n", branchName) | ||
| return nil | ||
|
Comment on lines
+321
to
322
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to print the success message in green is a nice touch. It makes the output more readable and helps the user quickly identify the success status.
Comment on lines
+321
to
322
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the color package to output green text is a nice touch for providing visual feedback to the user. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to see the use of the color package from github.com/fatih/color. This can enhance the user experience by providing colored output in the terminal.