47
52
func (c *SyncToolsCommand) SetFlags(f *gnuflag.FlagSet) {
48
53
c.EnvCommandBase.SetFlags(f)
49
54
f.BoolVar(&c.allVersions, "all", false, "copy all versions, not just the latest")
55
f.StringVar(&c.versionStr, "version", "", "copy a specific major[.minor] version")
50
56
f.BoolVar(&c.dryRun, "dry-run", false, "don't copy, just print what would be copied")
51
57
f.BoolVar(&c.dev, "dev", false, "consider development versions as well as released ones")
52
f.BoolVar(&c.publicBucket, "public", false, "write to the public-bucket of the account, instead of the bucket private to the environment.")
53
58
f.StringVar(&c.source, "source", "", "chose a location on the file system as source")
59
f.StringVar(&c.destination, "destination", "", "chose a location on the file system as destination")
55
61
// BUG(lp:1163164) jam 2013-04-2 we would like to add a "source"
56
62
// location, rather than only copying from us-east-1
59
65
func (c *SyncToolsCommand) Init(args []string) error {
66
if c.versionStr != "" {
68
if c.majorVersion, c.minorVersion, err = version.ParseMajorMinor(c.versionStr); err != nil {
60
72
return cmd.CheckEmpty(args)
63
75
func (c *SyncToolsCommand) Run(ctx *cmd.Context) error {
64
76
// Register writer for output on screen.
65
loggo.RegisterWriter("synctools", sync.NewSyncLogWriter(ctx.Stdout, ctx.Stderr), loggo.INFO)
77
loggo.RegisterWriter("synctools", cmd.NewCommandLogWriter("juju.environs.sync", ctx.Stdout, ctx.Stderr), loggo.INFO)
66
78
defer loggo.RemoveWriter("synctools")
67
79
environ, err := environs.PrepareFromName(c.EnvName)
84
target := environ.Storage()
85
if c.destination != "" {
86
target, err = filestorage.NewFileStorageWriter(c.destination)
71
92
// Prepare syncing.
72
93
sctx := &sync.SyncContext{
74
95
AllVersions: c.allVersions,
96
MajorVersion: c.majorVersion,
97
MinorVersion: c.minorVersion,
76
PublicBucket: c.publicBucket,