You've already forked panic-cli
mirror of
https://github.com/Print-and-Panic/panic-cli.git
synced 2026-01-21 10:17:41 -08:00
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package persona
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/Print-and-Panic/panic-cli/internal/config"
|
|
"github.com/Print-and-Panic/panic-cli/internal/system"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var statusCmd = &cobra.Command{
|
|
Use: "status",
|
|
Short: "Show the current persona",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
err := validatePersona()
|
|
if err != nil {
|
|
fmt.Printf("❌ %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
fmt.Printf("✅ Current persona: %s\n", config.AppConfig.PersonaManagement.CurrentPersona)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
PersonaCmd.AddCommand(statusCmd)
|
|
}
|
|
|
|
func validatePersona() error {
|
|
|
|
targetName := config.AppConfig.PersonaManagement.CurrentPersona
|
|
persona, exists := config.AppConfig.PersonaManagement.Personas[targetName]
|
|
if !exists {
|
|
return fmt.Errorf("persona '%s' not found", targetName)
|
|
}
|
|
|
|
currentId, err := system.CurrentSystem.GetCurrentGitIdentity()
|
|
if err == nil {
|
|
if currentId.Name != persona.GitName || currentId.Email != persona.GitEmail {
|
|
return fmt.Errorf("identity mismatch")
|
|
}
|
|
}
|
|
|
|
currentTheme, err := system.CurrentSystem.GetTheme()
|
|
if err != nil {
|
|
return fmt.Errorf("failed to get theme: %v", err)
|
|
}
|
|
|
|
fmt.Printf("Current Theme: '%s'\n", currentTheme)
|
|
if currentTheme != persona.KdeTheme {
|
|
return fmt.Errorf("theme mismatch")
|
|
}
|
|
|
|
return nil
|
|
}
|