Documentation
¶
Overview ¶
Package create implements 'rclone archive create'.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cobra.Command{ Use: "create [flags] <source> [<destination>]", Short: `Archive source file(s) to destination.`, Long: strings.ReplaceAll(` Creates an archive from the files in source:path and saves the archive to dest:path. If dest:path is missing, it will write to the console. The valid formats for the !--format! flag are listed below. If !--format! is not set rclone will guess it from the extension of dest:path. | Format | Extensions | |:-------|:-----------| | zip | .zip | | tar | .tar | | tar.gz | .tar.gz, .tgz, .taz | | tar.bz2| .tar.bz2, .tb2, .tbz, .tbz2, .tz2 | | tar.lz | .tar.lz | | tar.lz4| .tar.lz4 | | tar.xz | .tar.xz, .txz | | tar.zst| .tar.zst, .tzst | | tar.br | .tar.br | | tar.sz | .tar.sz | | tar.mz | .tar.mz | The !--prefix! and !--full-path! flags control the prefix for the files in the archive. If the flag !--full-path! is set then the files will have the full source path as the prefix. If the flag !--prefix=<value>! is set then the files will have !<value>! as prefix. It's possible to create invalid file names with !--prefix=<value>! so use with caution. Flag !--prefix! has priority over !--full-path!. Given a directory !/sourcedir! with the following: file1.txt dir1/file2.txt Running the command !rclone archive create /sourcedir /dest.tar.gz! will make an archive with the contents: file1.txt dir1/ dir1/file2.txt Running the command !rclone archive create --full-path /sourcedir /dest.tar.gz! will make an archive with the contents: sourcedir/file1.txt sourcedir/dir1/ sourcedir/dir1/file2.txt Running the command !rclone archive create --prefix=my_new_path /sourcedir /dest.tar.gz! will make an archive with the contents: my_new_path/file1.txt my_new_path/dir1/ my_new_path/dir1/file2.txt `, "!", "`"), Annotations: map[string]string{ "versionIntroduced": "v1.72", }, RunE: func(command *cobra.Command, args []string) error { var src, dst fs.Fs var dstFile string if len(args) == 1 { src = cmd.NewFsSrc(args) } else if len(args) == 2 { src = cmd.NewFsSrc(args) dst, dstFile = cmd.NewFsDstFile(args[1:2]) } else { cmd.CheckArgs(1, 2, command, args) } cmd.Run(false, false, command, func() error { fmt.Printf("dst=%v, dstFile=%q, src=%v, format=%q, prefix=%q\n", dst, dstFile, src, format, prefix) if prefix != "" { return ArchiveCreate(context.Background(), dst, dstFile, src, format, prefix) } else if fullPath { return ArchiveCreate(context.Background(), dst, dstFile, src, format, src.Root()) } return ArchiveCreate(context.Background(), dst, dstFile, src, format, "") }) return nil }, }
Command - create
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.