github.com/mutagen-io/mutagen@v0.18.0-rc1/cmd/mutagen/project/main.go (about)

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