1
0
Fork 0
mirror of https://github.com/Luzifer/s3sync.git synced 2024-10-18 06:24:20 +00:00

Fix: Move version info to flag instead of command

This commit is contained in:
Knut Ahlers 2015-07-26 16:22:32 +02:00
parent 54c49f55d1
commit e22b43ef38

14
main.go
View file

@ -16,6 +16,7 @@ var (
cfg = struct {
Delete bool
Public bool
PrintVersion bool
}{}
version = "dev"
)
@ -39,18 +40,17 @@ func main() {
Use: "s3sync <from> <to>",
Short: "Sync files from <from> to <to>",
Run: execSync,
}
app.AddCommand(&cobra.Command{
Use: "version",
Short: "Returns the current version of s3sync",
Run: func(cmd *cobra.Command, args []string) {
PreRun: func(cmd *cobra.Command, args []string) {
if cfg.PrintVersion {
fmt.Printf("s3sync %s\n", version)
os.Exit(0)
}
},
})
}
app.Flags().BoolVarP(&cfg.Public, "public", "P", false, "Make files public when syncing to S3")
app.Flags().BoolVarP(&cfg.Delete, "delete", "d", false, "Delete files on remote not existing on local")
app.Flags().BoolVarP(&cfg.PrintVersion, "version", "v", false, "Print version and quit")
app.Execute()
}