2022-08-28 13:21:57 +02:00
|
|
|
// Package serve provides the serve command.
|
2016-12-06 19:00:24 +01:00
|
|
|
package serve
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/cmd"
|
|
|
|
"github.com/rclone/rclone/cmd/serve/dlna"
|
2021-01-03 01:05:52 +01:00
|
|
|
"github.com/rclone/rclone/cmd/serve/docker"
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/cmd/serve/ftp"
|
|
|
|
"github.com/rclone/rclone/cmd/serve/http"
|
2023-10-04 19:28:41 +02:00
|
|
|
"github.com/rclone/rclone/cmd/serve/nfs"
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/cmd/serve/restic"
|
2022-09-21 17:09:50 +02:00
|
|
|
"github.com/rclone/rclone/cmd/serve/s3"
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/cmd/serve/sftp"
|
|
|
|
"github.com/rclone/rclone/cmd/serve/webdav"
|
2016-12-06 19:00:24 +01:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
Command.AddCommand(http.Command)
|
2018-11-25 17:34:51 +01:00
|
|
|
if webdav.Command != nil {
|
|
|
|
Command.AddCommand(webdav.Command)
|
|
|
|
}
|
2018-11-26 15:07:25 +01:00
|
|
|
if restic.Command != nil {
|
|
|
|
Command.AddCommand(restic.Command)
|
|
|
|
}
|
2019-01-03 23:23:50 +01:00
|
|
|
if dlna.Command != nil {
|
|
|
|
Command.AddCommand(dlna.Command)
|
|
|
|
}
|
2018-09-13 19:21:20 +02:00
|
|
|
if ftp.Command != nil {
|
|
|
|
Command.AddCommand(ftp.Command)
|
|
|
|
}
|
2019-05-10 20:00:18 +02:00
|
|
|
if sftp.Command != nil {
|
|
|
|
Command.AddCommand(sftp.Command)
|
|
|
|
}
|
2021-01-03 01:05:52 +01:00
|
|
|
if docker.Command != nil {
|
|
|
|
Command.AddCommand(docker.Command)
|
|
|
|
}
|
2023-10-04 19:28:41 +02:00
|
|
|
if nfs.Command != nil {
|
|
|
|
Command.AddCommand(nfs.Command)
|
|
|
|
}
|
2022-09-21 17:09:50 +02:00
|
|
|
if s3.Command != nil {
|
|
|
|
Command.AddCommand(s3.Command)
|
|
|
|
}
|
2016-12-06 19:00:24 +01:00
|
|
|
cmd.Root.AddCommand(Command)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Command definition for cobra
|
|
|
|
var Command = &cobra.Command{
|
|
|
|
Use: "serve <protocol> [opts] <remote>",
|
|
|
|
Short: `Serve a remote over a protocol.`,
|
2022-06-19 19:18:14 +02:00
|
|
|
Long: `Serve a remote over a given protocol. Requires the use of a
|
|
|
|
subcommand to specify the protocol, e.g.
|
2016-12-06 19:00:24 +01:00
|
|
|
|
|
|
|
rclone serve http remote:
|
|
|
|
|
|
|
|
Each subcommand has its own options which you can see in their help.
|
|
|
|
`,
|
2022-11-26 23:40:49 +01:00
|
|
|
Annotations: map[string]string{
|
|
|
|
"versionIntroduced": "v1.39",
|
|
|
|
},
|
2016-12-06 19:00:24 +01:00
|
|
|
RunE: func(command *cobra.Command, args []string) error {
|
|
|
|
if len(args) == 0 {
|
2020-10-13 23:49:58 +02:00
|
|
|
return errors.New("serve requires a protocol, e.g. 'rclone serve http remote:'")
|
2016-12-06 19:00:24 +01:00
|
|
|
}
|
|
|
|
return errors.New("unknown protocol")
|
|
|
|
},
|
|
|
|
}
|