forked from kardianos/govendor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync.go
34 lines (30 loc) · 939 Bytes
/
sync.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
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package run
import (
"flag"
"io"
"github.com/kardianos/govendor/context"
"github.com/kardianos/govendor/help"
)
func (r *runner) Sync(w io.Writer, subCmdArgs []string) (help.HelpMessage, error) {
flags := flag.NewFlagSet("sync", flag.ContinueOnError)
insecure := flags.Bool("insecure", false, "allow insecure network updates")
dryrun := flags.Bool("n", false, "dry run, print what would be done")
verbose := flags.Bool("v", false, "verbose output")
flags.SetOutput(nullWriter{})
err := flags.Parse(subCmdArgs)
if err != nil {
return help.MsgSync, err
}
ctx, err := r.NewContextWD(context.RootVendor)
if err != nil {
return help.MsgSync, err
}
ctx.Insecure = *insecure
if *dryrun || *verbose {
ctx.Logger = w
}
return help.MsgNone, ctx.Sync(*dryrun)
}