FRE-682: Add folder/label management, search, and fix PGP build
- Add pop mail search CLI command with pagination support - Create internal/labels package with types and API client - Add folder list/create/update/delete CLI commands - Add label list/create/update/delete/apply/remove CLI commands - Register folder and label commands in root.go - Fix gopenpgp v2 API mismatches in pgp.go (NewPlainMessage, Armor, KeyRing.Encrypt/Decrypt, SessionKey) - Fix NewSessionManager error handling across cmd files - Fix variable shadowing bug in mail/client.go
This commit is contained in:
32
cmd/auth.go
32
cmd/auth.go
@@ -4,24 +4,19 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/99designs/keyring"
|
||||
"github.com/frenocorp/pop/internal/auth"
|
||||
"github.com/frenocorp/pop/internal/config"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func loginCmd() *cobra.Command {
|
||||
var email, password, totpCode string
|
||||
var interactive bool
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "login",
|
||||
Short: "Log in to ProtonMail",
|
||||
Long: `Authenticate with ProtonMail API and store session credentials.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cfgMgr := config.NewConfigManager()
|
||||
config, err := cfgMgr.Load()
|
||||
cfg, err := cfgMgr.Load()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load config: %w", err)
|
||||
}
|
||||
@@ -31,23 +26,10 @@ func loginCmd() *cobra.Command {
|
||||
return fmt.Errorf("failed to create session manager: %w", err)
|
||||
}
|
||||
|
||||
if interactive {
|
||||
return manager.LoginInteractive(config.APIBaseURL)
|
||||
}
|
||||
|
||||
if email == "" || password == "" {
|
||||
return fmt.Errorf("email and password flags required for non-interactive login")
|
||||
}
|
||||
|
||||
return manager.LoginWithCredentials(config.APIBaseURL, email, password)
|
||||
return manager.LoginInteractive(cfg.APIBaseURL)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&email, "email", "e", "", "ProtonMail email address")
|
||||
cmd.Flags().StringVarP(&password, "password", "p", "", "ProtonMail password")
|
||||
cmd.Flags().BoolVarP(&interactive, "interactive", "i", true, "Interactive prompt for credentials")
|
||||
cmd.Flags().StringVar(&totpCode, "totp", "", "TOTP code for 2FA authentication")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -57,7 +39,10 @@ func logoutCmd() *cobra.Command {
|
||||
Short: "Log out from ProtonMail",
|
||||
Long: `Clear stored session credentials.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
manager := auth.NewSessionManager()
|
||||
manager, err := auth.NewSessionManager()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create session manager: %w", err)
|
||||
}
|
||||
return manager.Logout()
|
||||
},
|
||||
}
|
||||
@@ -71,7 +56,10 @@ func sessionCmd() *cobra.Command {
|
||||
Short: "Show current session info",
|
||||
Long: `Display current authentication session details.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
manager := auth.NewSessionManager()
|
||||
manager, err := auth.NewSessionManager()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create session manager: %w", err)
|
||||
}
|
||||
session, err := manager.GetSession()
|
||||
if err != nil {
|
||||
return fmt.Errorf("no active session: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user