mirror of
https://github.com/openziti/zrok.git
synced 2024-12-23 07:09:12 +01:00
cli lint (438)
This commit is contained in:
parent
b6629d7fb4
commit
4b7f5df1ee
@ -21,9 +21,10 @@ type copyCommand struct {
|
||||
|
||||
func newCopyCommand() *copyCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "copy <source> [<target>] (<target> defaults to 'file://.`)",
|
||||
Short: "Copy (unidirectional sync) zrok drive contents from <source> to <target> ('http://', 'file://', and 'zrok://' supported)",
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
Use: "copy <source> [<target>] (<target> defaults to 'file://.`)",
|
||||
Short: "Copy (unidirectional sync) zrok drive contents from <source> to <target> ('http://', 'file://', and 'zrok://' supported)",
|
||||
Aliases: []string{"cp"},
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
}
|
||||
command := ©Command{cmd: cmd}
|
||||
cmd.Run = command.run
|
||||
|
@ -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