1
0
Fork 0
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:
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 { 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{
Use: "version",
Short: "Returns the current version of s3sync",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("s3sync %s\n", version) 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.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()
} }