mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 05:33:11 +08:00
daf449b5f2
Fixes #4750 Co-authored-by: Ivan Andreev <ivandeex@gmail.com>
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package serve
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/rclone/rclone/cmd"
|
|
"github.com/rclone/rclone/cmd/serve/dlna"
|
|
"github.com/rclone/rclone/cmd/serve/docker"
|
|
"github.com/rclone/rclone/cmd/serve/ftp"
|
|
"github.com/rclone/rclone/cmd/serve/http"
|
|
"github.com/rclone/rclone/cmd/serve/restic"
|
|
"github.com/rclone/rclone/cmd/serve/sftp"
|
|
"github.com/rclone/rclone/cmd/serve/webdav"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
Command.AddCommand(http.Command)
|
|
if webdav.Command != nil {
|
|
Command.AddCommand(webdav.Command)
|
|
}
|
|
if restic.Command != nil {
|
|
Command.AddCommand(restic.Command)
|
|
}
|
|
if dlna.Command != nil {
|
|
Command.AddCommand(dlna.Command)
|
|
}
|
|
if ftp.Command != nil {
|
|
Command.AddCommand(ftp.Command)
|
|
}
|
|
if sftp.Command != nil {
|
|
Command.AddCommand(sftp.Command)
|
|
}
|
|
if docker.Command != nil {
|
|
Command.AddCommand(docker.Command)
|
|
}
|
|
cmd.Root.AddCommand(Command)
|
|
}
|
|
|
|
// Command definition for cobra
|
|
var Command = &cobra.Command{
|
|
Use: "serve <protocol> [opts] <remote>",
|
|
Short: `Serve a remote over a protocol.`,
|
|
Long: `rclone serve is used to serve a remote over a given protocol. This
|
|
command requires the use of a subcommand to specify the protocol, e.g.
|
|
|
|
rclone serve http remote:
|
|
|
|
Each subcommand has its own options which you can see in their help.
|
|
`,
|
|
RunE: func(command *cobra.Command, args []string) error {
|
|
if len(args) == 0 {
|
|
return errors.New("serve requires a protocol, e.g. 'rclone serve http remote:'")
|
|
}
|
|
return errors.New("unknown protocol")
|
|
},
|
|
}
|