This commit is contained in:
Christoph Polcin 2014-10-24 14:04:43 +02:00
parent b781d56161
commit c4b0d5c93d

View File

@ -1,10 +1,10 @@
package main package main
import ( import (
d "gowebdav"
"flag" "flag"
"os"
"fmt" "fmt"
d "gowebdav"
"os"
"strings" "strings"
) )
@ -44,47 +44,50 @@ func main() {
if alen == 1 { if alen == 1 {
path := flag.Args()[0] path := flag.Args()[0]
switch *m { switch *m {
case "LS", "LIST", "PROPFIND": case "LS", "LIST", "PROPFIND":
if files, err := c.ReadDir(path); err == nil { if files, err := c.ReadDir(path); err == nil {
fmt.Println(fmt.Sprintf("ReadDir: '%s' entries: %d ", path, len(files))) fmt.Println(fmt.Sprintf("ReadDir: '%s' entries: %d ", path, len(files)))
for _, f := range files { for _, f := range files {
fmt.Println(f) fmt.Println(f)
}
} else {
fmt.Println(err)
} }
} else {
fmt.Println(err)
}
case "GET": c.Read(path) case "GET":
c.Read(path)
case "DELETE", "RM", "DEL": case "DELETE", "RM", "DEL":
if err := c.Remove(path); err != nil { if err := c.Remove(path); err != nil {
fmt.Println(err) fmt.Println(err)
} else { } else {
fmt.Println("Remove: " + path) fmt.Println("Remove: " + path)
} }
case "MKCOL", "MKDIR": case "MKCOL", "MKDIR":
if err := c.Mkdir(path, 0); err != nil { if err := c.Mkdir(path, 0); err != nil {
fmt.Println(err) fmt.Println(err)
} else { } else {
fmt.Println("MkDir: " + path) fmt.Println("MkDir: " + path)
} }
case "MKCOLALL", "MKDIRALL": case "MKCOLALL", "MKDIRALL":
if err := c.MkdirAll(path, 0); err != nil { if err := c.MkdirAll(path, 0); err != nil {
fmt.Println(err) fmt.Println(err)
} else { } else {
fmt.Println("MkDirAll: " + path) fmt.Println("MkDirAll: " + path)
} }
default: Fail(nil) default:
Fail(nil)
} }
} else if alen == 2 { } else if alen == 2 {
a0 := flag.Args()[0] a0 := flag.Args()[0]
a1 := flag.Args()[1] a1 := flag.Args()[1]
switch *m { switch *m {
default: Fail(nil) default:
Fail(nil)
} }
} else { } else {
Fail(nil) Fail(nil)