esync

Directory watching and remote syncing
Log | Files | Refs | README | LICENSE

root.go (717B)


      1 package cmd
      2 
      3 import (
      4 	"fmt"
      5 	"os"
      6 
      7 	"github.com/spf13/cobra"
      8 
      9 	"github.com/louloulibs/esync/internal/syncer"
     10 )
     11 
     12 var cfgFile string
     13 
     14 var rootCmd = &cobra.Command{
     15 	Use:   "esync",
     16 	Short: "File synchronization tool using rsync",
     17 	Long:  "A file sync tool that watches for changes and automatically syncs them to a remote destination using rsync.",
     18 	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
     19 		_, err := syncer.CheckRsync()
     20 		if err != nil {
     21 			return err
     22 		}
     23 		return nil
     24 	},
     25 }
     26 
     27 func Execute() {
     28 	if err := rootCmd.Execute(); err != nil {
     29 		fmt.Fprintln(os.Stderr, err)
     30 		os.Exit(1)
     31 	}
     32 }
     33 
     34 func init() {
     35 	rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file path")
     36 }