2020-01-09 14:33:44 +01:00
|
|
|
// +build !simple
|
|
|
|
|
|
2019-09-05 12:06:03 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
|
|
import (
|
2020-02-10 17:04:40 +01:00
|
|
|
"github.com/micro/cli/v2"
|
2019-12-10 15:24:01 +01:00
|
|
|
"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.
|
2020-02-10 17:04:40 +01:00
|
|
|
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 {
|
2020-03-17 15:01:09 +01:00
|
|
|
webdavCommand := command.Server(configureWebDAV(cfg))
|
2019-12-10 15:24:01 +01:00
|
|
|
|
2020-03-17 15:01:09 +01:00
|
|
|
if err := webdavCommand.Before(c); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cli.HandleAction(webdavCommand.Action, c)
|
2019-12-10 15:24:01 +01:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
return cfg.WebDAV
|
|
|
|
|
}
|
2019-09-05 12:06:03 +02:00
|
|
|
|
2019-12-13 10:15:03 +01:00
|
|
|
func init() {
|
|
|
|
|
register.AddCommand(WebDAVCommand)
|
|
|
|
|
}
|