organized files

This commit is contained in:
Daveberry committed 2026-06-12 19:05:41 +08:00
1 parent d5f6dc6fa0
commit 2e8eceb1e2
9 files changed
+116 -86

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
package switchcmd
import (
"fmt"
"os"
"path/filepath"
"github.com/daveberrys/guh/src/utils"
)
func performAccountSwitch(username string) error {
account, err := utils.FindAccount(username)
if err != nil { return err }
if err := utils.RunGitSequence(false,
[]string{"config", "--global", "user.name", account.Username},
[]string{"config", "--global", "user.email", account.Email},
); err != nil { return err }
homeDir, err := os.UserHomeDir()
if err != nil { return err }
credentials := fmt.Sprintf("https://%s:%s@github.com\n", account.Username, account.ClassicToken)
if err := os.WriteFile(filepath.Join(homeDir, ".git-credentials"), []byte(credentials), 0600); err != nil { return err }
fmt.Printf("Switched to account: %s\n", account.Username)
return nil
}