From 31e0b57e53c0a333be61c00f4fc754ecc27299da Mon Sep 17 00:00:00 2001 From: Christoph Polcin Date: Fri, 25 May 2018 20:27:55 +0200 Subject: [PATCH] cmd: PUT with optinal FILE argument --- cmd/gowebdav/main.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/gowebdav/main.go b/cmd/gowebdav/main.go index fde6ab5..b2eb7cb 100644 --- a/cmd/gowebdav/main.go +++ b/cmd/gowebdav/main.go @@ -23,7 +23,7 @@ func main() { MKDIRALL GET [] - PUT + PUT [] MV CP @@ -164,11 +164,17 @@ func cmdCp(c *d.Client, p0, p1 string) (err error) { } func cmdPut(c *d.Client, p0, p1 string) (err error) { + if p1 == "" { + p1 = filepath.Join(".", p0) + } stream, err := getStream(p1) - if err == nil { - if err = c.WriteStream(p0, stream, 0644); err == nil { - fmt.Println(fmt.Sprintf("Put: '%s' -> %s", p1, p0)) - } + if err != nil { + return + } + defer stream.Close() + + if err = c.WriteStream(p0, stream, 0644); err == nil { + fmt.Println("Put: " + p1 + " -> " + p0) } return }