2020-01-09 14:33:44 +01:00
|
|
|
// +build !simple
|
|
|
|
|
|
2019-09-05 12:06:03 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
|
|
import (
|
2019-12-10 15:24:01 +01:00
|
|
|
"github.com/micro/cli"
|
|
|
|
|
"github.com/owncloud/ocis-webdav/pkg/command"
|
|
|
|
|
svcconfig "github.com/owncloud/ocis-webdav/pkg/config"
|
|
|
|
|
"github.com/owncloud/ocis-webdav/pkg/flagset"
|
|
|
|
|
"github.com/owncloud/ocis/pkg/config"
|
2019-12-13 10:15:03 +01:00
|
|
|
"github.com/owncloud/ocis/pkg/register"
|
2019-09-05 12:06:03 +02:00
|
|
|
)
|
|
|
|
|
|
2019-12-10 15:24:01 +01:00
|
|
|
// WebDAVCommand is the entrypoint for the webdav command.
|
|
|
|
|
func WebDAVCommand(cfg *config.Config) cli.Command {
|
|
|
|
|
return cli.Command{
|
2019-12-17 11:43:58 +01:00
|
|
|
Name: "webdav",
|
|
|
|
|
Usage: "Start webdav server",
|
|
|
|
|
Category: "Extensions",
|
|
|
|
|
Flags: flagset.ServerWithConfig(cfg.WebDAV),
|
2019-12-10 15:24:01 +01:00
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
scfg := configureWebDAV(cfg)
|
|
|
|
|
|
|
|
|
|
return cli.HandleAction(
|
|
|
|
|
command.Server(scfg).Action,
|
|
|
|
|
c,
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func configureWebDAV(cfg *config.Config) *svcconfig.Config {
|
|
|
|
|
cfg.WebDAV.Log.Level = cfg.Log.Level
|
|
|
|
|
cfg.WebDAV.Log.Pretty = cfg.Log.Pretty
|
|
|
|
|
cfg.WebDAV.Log.Color = cfg.Log.Color
|
|
|
|
|
cfg.WebDAV.Tracing.Enabled = false
|
2019-12-13 10:37:06 +01:00
|
|
|
cfg.WebDAV.HTTP.Addr = "localhost:9115"
|
2019-12-10 15:24:01 +01:00
|
|
|
cfg.WebDAV.HTTP.Root = "/"
|
|
|
|
|
|
|
|
|
|
return cfg.WebDAV
|
|
|
|
|
}
|
2019-09-05 12:06:03 +02:00
|
|
|
|
2019-12-13 10:15:03 +01:00
|
|
|
func init() {
|
|
|
|
|
register.AddCommand(WebDAVCommand)
|
|
|
|
|
}
|