github.com/mutagen-io/mutagen@v0.18.0-rc1/cmd/mutagen/sync/main.go (about) 1 package sync 2 3 import ( 4 "github.com/spf13/cobra" 5 ) 6 7 // syncMain is the entry point for the sync command. 8 func syncMain(command *cobra.Command, arguments []string) error { 9 // If no commands were given, then print help information and bail. We don't 10 // have to worry about warning about arguments being present here (which 11 // would be incorrect usage) because arguments can't even reach this point 12 // (they will be mistaken for subcommands and a error will be displayed). 13 command.Help() 14 15 // Success. 16 return nil 17 } 18 19 // SyncCommand is the sync command. 20 var SyncCommand = &cobra.Command{ 21 Use: "sync", 22 Short: "Create and manage file synchronization sessions", 23 RunE: syncMain, 24 SilenceUsage: true, 25 } 26 27 // syncConfiguration stores configuration for the sync command. 28 var syncConfiguration struct { 29 // help indicates whether or not to show help information and exit. 30 help bool 31 } 32 33 func init() { 34 // Grab a handle for the command line flags. 35 flags := SyncCommand.Flags() 36 37 // Disable alphabetical sorting of flags in help output. 38 flags.SortFlags = false 39 40 // Manually add a help flag to override the default message. Cobra will 41 // still implement its logic automatically. 42 flags.BoolVarP(&syncConfiguration.help, "help", "h", false, "Show help information") 43 44 // Register commands. 45 SyncCommand.AddCommand( 46 createCommand, 47 listCommand, 48 monitorCommand, 49 flushCommand, 50 pauseCommand, 51 resumeCommand, 52 resetCommand, 53 terminateCommand, 54 ) 55 }