/ cmd / keepsync / cmd / version / list.go
list.go
 1  // Package version implements version-related commands
 2  package version
 3  
 4  import (
 5  	"context"
 6  	"fmt"
 7  
 8  	"keepSync/internal/providers"
 9  
10  	"github.com/spf13/cobra"
11  )
12  
13  var (
14  	// List command flags
15  	listProviderType string
16  	listLimit        int
17  )
18  
19  // listCmd represents the version list command
20  var listCmd = &cobra.Command{
21  	Use:   "list [remote-path]",
22  	Short: "List all versions of a file",
23  	Long:  `List all versions of a file from remote storage.`,
24  	Args:  cobra.ExactArgs(1),
25  	RunE: func(cmd *cobra.Command, args []string) error {
26  		remotePath := args[0]
27  
28  		// Parse remote path to determine provider type
29  		providerType, remotePath, err := parseRemotePath(remotePath)
30  		if err != nil {
31  			return err
32  		}
33  
34  		// Override provider type if specified
35  		if listProviderType != "" {
36  			providerType = listProviderType
37  		}
38  
39  		// Create provider using quantum factory
40  		factory := providers.GetDefaultFactory()
41  		p, err := factory.CreateProvider(context.Background(), providers.ProviderConfig{
42  			Type: providerType,
43  			Config: map[string]interface{}{
44  				"path": remotePath,
45  			},
46  			QuantumEnabled: true,
47  		})
48  		if err != nil {
49  			return fmt.Errorf("failed to create provider: %w", err)
50  		}
51  		defer p.Close()
52  
53  		// Note: Versioning operations need to be implemented in quantum providers
54  		// For now, return an informative error
55  		return fmt.Errorf("version operations are being migrated to quantum providers - feature temporarily unavailable")
56  	},
57  }
58  
59  func init() {
60  	// Add list command to version command
61  	AddCommand(listCmd)
62  
63  	// Add flags to list command
64  	listCmd.Flags().StringVar(&listProviderType, "provider", "", "Override provider type (s3, webdav, sftp)")
65  	listCmd.Flags().IntVarP(&listLimit, "limit", "l", 10, "Maximum number of versions to list")
66  }