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

20
main.go
View file

@ -14,8 +14,9 @@ import (
var ( var (
cfg = struct { cfg = struct {
Delete bool Delete bool
Public bool Public bool
PrintVersion bool
}{} }{}
version = "dev" version = "dev"
) )
@ -39,18 +40,17 @@ func main() {
Use: "s3sync <from> <to>", Use: "s3sync <from> <to>",
Short: "Sync files from <from> to <to>", Short: "Sync files from <from> to <to>",
Run: execSync, Run: execSync,
} PreRun: func(cmd *cobra.Command, args []string) {
if cfg.PrintVersion {
app.AddCommand(&cobra.Command{ fmt.Printf("s3sync %s\n", version)
Use: "version", os.Exit(0)
Short: "Returns the current version of s3sync", }
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("s3sync %s\n", version)
}, },
}) }
app.Flags().BoolVarP(&cfg.Public, "public", "P", false, "Make files public when syncing to S3") 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.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() app.Execute()
} }