Tidy up command structure for MCP Publisher (#324)

## Summary
- Improved command structure and organization for the MCP Publisher CLI
- Enhanced readability and maintainability of publisher commands
- Cleaned up publish and edit handler logic

This builds on the previous cleanup work to further streamline the
publisher interface.

This also works as part of
https://github.com/modelcontextprotocol/registry/issues/89
This commit is contained in:
adam jones 2025-08-29 12:44:49 +01:00 • committed by GitHub
commit b8106340bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,43 @@
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
}