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

     1  package forward
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  )
     6  
     7  // forwardMain is the entry point for the forward command.
     8  func forwardMain(command *cobra.Command, _ []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  // ForwardCommand is the forward command.
    20  var ForwardCommand = &cobra.Command{
    21  	Use:          "forward",
    22  	Short:        "Create and manage network forwarding sessions",
    23  	RunE:         forwardMain,
    24  	SilenceUsage: true,
    25  }
    26  
    27  // forwardConfiguration stores configuration for the forward command.
    28  var forwardConfiguration 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 := ForwardCommand.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(&forwardConfiguration.help, "help", "h", false, "Show help information")
    43  
    44  	// Register commands.
    45  	ForwardCommand.AddCommand(
    46  		createCommand,
    47  		listCommand,
    48  		monitorCommand,
    49  		pauseCommand,
    50  		resumeCommand,
    51  		terminateCommand,
    52  	)
    53  }