/ cmd / keepsync / cmd / root.go.bak
root.go.bak
 1  // Package cmd implements the command-line interface for KeepSync
 2  package cmd
 3  
 4  import (
 5  	"context"
 6  	
 7  	"keepSync/internal/logging"
 8  	"keepSync/internal/provider"
 9  	"keepSync/internal/services"
10  	
11  	"keepSync/cmd/keepsync/cmd/advanced"
12  	"keepSync/cmd/keepsync/cmd/security"
13  	"keepSync/cmd/keepsync/cmd/version"
14  	
15  	"github.com/spf13/cobra"
16  )
17  
18  var (
19  	// Global flags
20  	verbose    bool
21  	configFile string
22  	
23  	// Commands
24  	initCmd *cobra.Command
25  	syncCmd *cobra.Command
26  	
27  	// Provider factory
28  	providerFactory provider.ProviderFactory
29  	
30  	// Logger
31  	logger logging.Logger
32  )
33  
34  // rootCmd represents the base command when called without any subcommands
35  var rootCmd = &cobra.Command{
36  	Use:   "keepsync",
37  	Short: "KeepSync secure cloud synchronization tool",
38  	Long: `KeepSync is a secure file synchronization tool that supports 
39  multiple cloud providers and advanced security features including 
40  TPM-based security, quantum-resistant encryption, and key revocation.`,
41  }
42  
43  // Execute adds all child commands to the root command and sets flags appropriately.
44  // This is called by main.main(). It only needs to happen once to the rootCmd.
45  func Execute() error {
46  	return rootCmd.Execute()
47  }
48  
49  func init() {
50  	// Create logger
51  	logger = logging.GetLogger("keepsync")
52  	
53  	// Create provider factory
54  	factory := provider.NewFactory(logger)
55  	providerFactory = factory
56  	
57  	// Register provider factory
58  	provider.RegisterFactory(factory)
59  	
60  	// Initialize commands
61  	initCmd = InitializeInitCommand(logger, providerFactory)
62  	syncCmd = InitializeSyncCommand(logger, providerFactory)
63  	
64  	// Add global flags
65  	rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose output")
66  	rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "Config file (default is $HOME/.keepsync/config.json)")
67  	
68  	// Add commands
69  	rootCmd.AddCommand(initCmd)
70  	rootCmd.AddCommand(syncCmd)
71  	rootCmd.AddCommand(security.NewSecurityCommand())
72  	rootCmd.AddCommand(advanced.NewAdvancedCommand())
73  	rootCmd.AddCommand(version.NewVersionCommand())
74  }