-
Notifications
You must be signed in to change notification settings - Fork 147
/
main.go
50 lines (40 loc) · 1.6 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package sync
import (
"github.com/spf13/cobra"
// Explicitly import packages that need to register protocol handlers.
_ "github.com/mutagen-io/mutagen/pkg/synchronization/protocols/docker"
_ "github.com/mutagen-io/mutagen/pkg/synchronization/protocols/local"
_ "github.com/mutagen-io/mutagen/pkg/synchronization/protocols/ssh"
)
func rootMain(command *cobra.Command, arguments []string) error {
// If no commands were given, then print help information and bail. We don't
// have to worry about warning about arguments being present here (which
// would be incorrect usage) because arguments can't even reach this point
// (they will be mistaken for subcommands and a error will be displayed).
command.Help()
// Success.
return nil
}
var RootCommand = &cobra.Command{
Use: "sync",
Short: "Create and manage synchronization sessions",
RunE: rootMain,
SilenceUsage: true,
}
var rootConfiguration struct {
// help indicates whether or not help information should be shown for the
// command.
help bool
}
func init() {
// Grab a handle for the command line flags.
flags := RootCommand.Flags()
// Disable alphabetical sorting of flags in help output.
flags.SortFlags = false
// Manually add a help flag to override the default message. Cobra will
// still implement its logic automatically.
flags.BoolVarP(&rootConfiguration.help, "help", "h", false, "Show help information")
// HACK: In order for the sync commands to have the correct parent, we have
// to add them to the sync command after we add them to the root command.
// Thus, we add them in the top-level init function.
}