Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[cli] Extend export command to pass filters

Neeraj Gupta0526c63681e8
diff --git a/cli/cmd/export.go b/cli/cmd/export.go
index 57548c4fe5..fa253cce64 100644
--- a/cli/cmd/export.go
+++ b/cli/cmd/export.go
@@ -1,19 +1,44 @@
package cmd
import (
+ "github.com/ente-io/cli/pkg/model/export"
"github.com/spf13/cobra"
)
-// versionCmd represents the version command
+// exportCmd represents the export command
var exportCmd = &cobra.Command{
Use: "export",
Short: "Starts the export process",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- ctrl.Export()
+ // Retrieve flag values
+ shared, _ := cmd.Flags().GetBool("shared")
+ sharedFiles, _ := cmd.Flags().GetBool("shared-files")
+ hidden, _ := cmd.Flags().GetBool("hidden")
+ albums, _ := cmd.Flags().GetStringSlice("albums")
+ emails, _ := cmd.Flags().GetStringSlice("emails")
+
+ // Create Filters struct with flag values
+ filters := export.Filters{
+ ExcludeShared: !shared,
+ ExcludeSharedFiles: !sharedFiles,
+ ExcludeHidden: !hidden,
+ Albums: albums,
+ Emails: emails,
+ }
+
+ // Call the Export function with the filters
+ ctrl.Export(filters)
},
}
func init() {
rootCmd.AddCommand(exportCmd)
+
+ // Add flags for Filters struct fields with default value true
+ exportCmd.Flags().Bool("shared", true, "Include shared albums in export")
+ exportCmd.Flags().Bool("shared-files", true, "Include shared files in export")
+ exportCmd.Flags().Bool("hidden", true, "Include hidden albums in export")
+ exportCmd.Flags().StringSlice("albums", []string{}, "Comma-separated list of album names to export")
+ exportCmd.Flags().StringSlice("emails", []string{}, "Comma-separated list of emails to export files shared with")
}
diff --git a/cli/pkg/sync.go b/cli/pkg/sync.go
index 6aee7cbb75..d6cbf06bf5 100644
--- a/cli/pkg/sync.go
+++ b/cli/pkg/sync.go
@@ -7,12 +7,13 @@ import (
"github.com/ente-io/cli/internal"
"github.com/ente-io/cli/internal/api"
"github.com/ente-io/cli/pkg/model"
+ "github.com/ente-io/cli/pkg/model/export"
bolt "go.etcd.io/bbolt"
"log"
"time"
)
-func (c *ClICtrl) Export() error {
+func (c *ClICtrl) Export(filters export.Filters) error {
accounts, err := c.GetAccounts(context.Background())
if err != nil {
return err