2016-12-07 02:00:24 +08:00
|
|
|
package serve
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/ncw/rclone/cmd"
|
2019-05-11 02:00:18 +08:00
|
|
|
"github.com/ncw/rclone/cmd/serve/dlna"
|
2018-03-25 23:03:37 +08:00
|
|
|
"github.com/ncw/rclone/cmd/serve/ftp"
|
2016-12-07 02:00:24 +08:00
|
|
|
"github.com/ncw/rclone/cmd/serve/http"
|
2018-02-18 07:25:59 +08:00
|
|
|
"github.com/ncw/rclone/cmd/serve/restic"
|
2019-05-11 02:00:18 +08:00
|
|
|
"github.com/ncw/rclone/cmd/serve/sftp"
|
2017-04-25 21:57:59 +08:00
|
|
|
"github.com/ncw/rclone/cmd/serve/webdav"
|
2016-12-07 02:00:24 +08:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
Command.AddCommand(http.Command)
|
2018-11-26 00:34:51 +08:00
|
|
|
if webdav.Command != nil {
|
|
|
|
Command.AddCommand(webdav.Command)
|
|
|
|
}
|
2018-11-26 22:07:25 +08:00
|
|
|
if restic.Command != nil {
|
|
|
|
Command.AddCommand(restic.Command)
|
|
|
|
}
|
2019-01-04 06:23:50 +08:00
|
|
|
if dlna.Command != nil {
|
|
|
|
Command.AddCommand(dlna.Command)
|
|
|
|
}
|
2018-09-14 01:21:20 +08:00
|
|
|
if ftp.Command != nil {
|
|
|
|
Command.AddCommand(ftp.Command)
|
|
|
|
}
|
2019-05-11 02:00:18 +08:00
|
|
|
if sftp.Command != nil {
|
|
|
|
Command.AddCommand(sftp.Command)
|
|
|
|
}
|
2016-12-07 02:00:24 +08: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.`,
|
|
|
|
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, eg
|
|
|
|
|
|
|
|
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, eg 'rclone serve http remote:'")
|
|
|
|
}
|
|
|
|
return errors.New("unknown protocol")
|
|
|
|
},
|
|
|
|
}
|