rc: take note of the --rc-addr flag too as per the docs - fixes #2184

This commit is contained in:
Nick Craig-Wood 2018-04-26 16:59:10 +01:00
parent 849db6699d
commit d8e88f10cd

View file

@ -14,6 +14,7 @@ import (
"github.com/ncw/rclone/fs/rc" "github.com/ncw/rclone/fs/rc"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag"
) )
var ( var (
@ -57,6 +58,14 @@ func doCall(path string, in rc.Params) (out rc.Params, err error) {
// Do HTTP request // Do HTTP request
client := fshttp.NewClient(fs.Config) client := fshttp.NewClient(fs.Config)
url := url url := url
// set the user use --rc-addr as well as --url
if rcAddrFlag := pflag.Lookup("rc-addr"); rcAddrFlag != nil && rcAddrFlag.Changed {
url = rcAddrFlag.Value.String()
if strings.HasPrefix(url, ":") {
url = "localhost" + url
}
url = "http://" + url + "/"
}
if !strings.HasSuffix(url, "/") { if !strings.HasSuffix(url, "/") {
url += "/" url += "/"
} }