mirror of
https://github.com/Luzifer/s3sync.git
synced 2024-12-20 19:41:15 +00:00
Fix: Move version info to flag instead of command
This commit is contained in:
parent
54c49f55d1
commit
e22b43ef38
1 changed files with 10 additions and 10 deletions
20
main.go
20
main.go
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue