-
Notifications
You must be signed in to change notification settings - Fork 2
/
get.go
43 lines (33 loc) · 966 Bytes
/
get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cli
import (
"github.com/jessevdk/go-flags"
"github.com/pkg/errors"
clientcmd "github.com/dpb587/ssoca/client/cmd"
svc "github.com/dpb587/ssoca/service/file/client"
)
type Get struct {
*ServiceCommand `no-flag:"true"`
clientcmd.InteractiveAuthCommand
serviceFactory svc.ServiceFactory
Args GetArgs `positional-args:"true"`
}
var _ flags.Commander = Get{}
type GetArgs struct {
File string `positional-arg-name:"FILE" description:"File name" required:"true"`
TargetFile string `positional-arg-name:"TARGET-FILE" description:"Target path to write download (use '-' for STDOUT)"`
}
func (c Get) Execute(_ []string) error {
service, err := c.GetService()
if err != nil {
return errors.Wrap(err, "getting service")
}
err = service.Get(svc.GetOptions{
SkipAuthRetry: c.SkipAuthRetry,
RemoteFile: c.Args.File,
LocalFile: c.Args.TargetFile,
})
if err != nil {
return errors.Wrap(err, "getting file")
}
return nil
}