mirror of
https://github.com/openziti/zrok.git
synced 2025-01-11 00:18:43 +01:00
cli lint (438)
This commit is contained in:
parent
b6629d7fb4
commit
4b7f5df1ee
@ -23,6 +23,7 @@ func newCopyCommand() *copyCommand {
|
|||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "copy <source> [<target>] (<target> defaults to 'file://.`)",
|
Use: "copy <source> [<target>] (<target> defaults to 'file://.`)",
|
||||||
Short: "Copy (unidirectional sync) zrok drive contents from <source> to <target> ('http://', 'file://', and 'zrok://' supported)",
|
Short: "Copy (unidirectional sync) zrok drive contents from <source> to <target> ('http://', 'file://', and 'zrok://' supported)",
|
||||||
|
Aliases: []string{"cp"},
|
||||||
Args: cobra.RangeArgs(1, 2),
|
Args: cobra.RangeArgs(1, 2),
|
||||||
}
|
}
|
||||||
command := ©Command{cmd: cmd}
|
command := ©Command{cmd: cmd}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"github.com/openziti/zrok/drives/davClient"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
rootCmd.AddCommand(newDavtestCommand().cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
type davtestCommand struct {
|
|
||||||
cmd *cobra.Command
|
|
||||||
}
|
|
||||||
|
|
||||||
func newDavtestCommand() *davtestCommand {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "davtest",
|
|
||||||
Short: "WebDAV testing wrapper",
|
|
||||||
Args: cobra.ExactArgs(3),
|
|
||||||
}
|
|
||||||
command := &davtestCommand{cmd: cmd}
|
|
||||||
cmd.Run = command.run
|
|
||||||
return command
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cmd *davtestCommand) run(_ *cobra.Command, args []string) {
|
|
||||||
client, err := davClient.NewClient(http.DefaultClient, args[0])
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
ws, err := client.Open(context.Background(), args[1])
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
fs, err := os.Create(args[2])
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
_, err = io.Copy(fs, ws)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
ws.Close()
|
|
||||||
fs.Close()
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user