## Summary - Applied `gofmt -s -w` across the entire codebase to ensure consistent Go formatting - This will trigger a deployment with minimal code changes ## Test plan - [x] Pre-commit hooks pass - [x] No functional changes, formatting only 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
43 lines
939 B
Go
43 lines
939 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func LogoutCommand() error {
|
|
homeDir, err := os.UserHomeDir()
|
|
if err != nil {
|
|
return fmt.Errorf("failed to get home directory: %w", err)
|
|
}
|
|
|
|
tokenPath := filepath.Join(homeDir, TokenFileName)
|
|
|
|
// Check if token file exists
|
|
if _, err := os.Stat(tokenPath); os.IsNotExist(err) {
|
|
_, _ = fmt.Fprintln(os.Stdout, "Not logged in")
|
|
return nil
|
|
}
|
|
|
|
// Remove token file
|
|
if err := os.Remove(tokenPath); err != nil {
|
|
return fmt.Errorf("failed to remove token: %w", err)
|
|
}
|
|
|
|
// Also clean up legacy token files if they exist
|
|
legacyFiles := []string{
|
|
".mcpregistry_github_token",
|
|
".mcpregistry_registry_token",
|
|
}
|
|
|
|
for _, file := range legacyFiles {
|
|
path := filepath.Join(homeDir, file)
|
|
if _, err := os.Stat(path); err == nil {
|
|
os.Remove(path) // Ignore errors for legacy files
|
|
}
|
|
}
|
|
|
|
_, _ = fmt.Fprintln(os.Stdout, "✓ Successfully logged out")
|
|
return nil
|
|
}
|