github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/fs/filter/filterflags/filterflags.go (about) 1 // Package filterflags implements command line flags to set up a filter 2 package filterflags 3 4 import ( 5 "github.com/rclone/rclone/fs/config/flags" 6 "github.com/rclone/rclone/fs/filter" 7 "github.com/rclone/rclone/fs/rc" 8 "github.com/spf13/pflag" 9 ) 10 11 // Options set by command line flags 12 var ( 13 Opt = filter.DefaultOpt 14 ) 15 16 // Reload the filters from the flags 17 func Reload() (err error) { 18 filter.Active, err = filter.NewFilter(&Opt) 19 return err 20 } 21 22 // AddFlags adds the non filing system specific flags to the command 23 func AddFlags(flagSet *pflag.FlagSet) { 24 rc.AddOptionReload("filter", &Opt, Reload) 25 flags.BoolVarP(flagSet, &Opt.DeleteExcluded, "delete-excluded", "", false, "Delete files on dest excluded from sync") 26 flags.StringArrayVarP(flagSet, &Opt.FilterRule, "filter", "f", nil, "Add a file-filtering rule") 27 flags.StringArrayVarP(flagSet, &Opt.FilterFrom, "filter-from", "", nil, "Read filtering patterns from a file (use - to read from stdin)") 28 flags.StringArrayVarP(flagSet, &Opt.ExcludeRule, "exclude", "", nil, "Exclude files matching pattern") 29 flags.StringArrayVarP(flagSet, &Opt.ExcludeFrom, "exclude-from", "", nil, "Read exclude patterns from file (use - to read from stdin)") 30 flags.StringVarP(flagSet, &Opt.ExcludeFile, "exclude-if-present", "", "", "Exclude directories if filename is present") 31 flags.StringArrayVarP(flagSet, &Opt.IncludeRule, "include", "", nil, "Include files matching pattern") 32 flags.StringArrayVarP(flagSet, &Opt.IncludeFrom, "include-from", "", nil, "Read include patterns from file (use - to read from stdin)") 33 flags.StringArrayVarP(flagSet, &Opt.FilesFrom, "files-from", "", nil, "Read list of source-file names from file (use - to read from stdin)") 34 flags.StringArrayVarP(flagSet, &Opt.FilesFromRaw, "files-from-raw", "", nil, "Read list of source-file names from file without any processing of lines (use - to read from stdin)") 35 flags.FVarP(flagSet, &Opt.MinAge, "min-age", "", "Only transfer files older than this in s or suffix ms|s|m|h|d|w|M|y") 36 flags.FVarP(flagSet, &Opt.MaxAge, "max-age", "", "Only transfer files younger than this in s or suffix ms|s|m|h|d|w|M|y") 37 flags.FVarP(flagSet, &Opt.MinSize, "min-size", "", "Only transfer files bigger than this in k or suffix b|k|M|G") 38 flags.FVarP(flagSet, &Opt.MaxSize, "max-size", "", "Only transfer files smaller than this in k or suffix b|k|M|G") 39 flags.BoolVarP(flagSet, &Opt.IgnoreCase, "ignore-case", "", false, "Ignore case in filters (case insensitive)") 40 //cvsExclude = BoolP("cvs-exclude", "C", false, "Exclude files in the same way CVS does") 41 }