github.com/armen/terraform@v0.5.2-0.20150529052519-caa8117a08f1/command/remote.go (about)

     1  package command
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  type RemoteCommand struct {
     8  	Meta
     9  }
    10  
    11  func (c *RemoteCommand) Run(argsRaw []string) int {
    12  	// Duplicate the args so we can munge them without affecting
    13  	// future subcommand invocations which will do the same.
    14  	args := make([]string, len(argsRaw))
    15  	copy(args, argsRaw)
    16  	args = c.Meta.process(args, false)
    17  
    18  	if len(args) == 0 {
    19  		c.Ui.Error(c.Help())
    20  		return 1
    21  	}
    22  
    23  	switch args[0] {
    24  	case "config":
    25  		cmd := &RemoteConfigCommand{Meta: c.Meta}
    26  		return cmd.Run(args[1:])
    27  	case "pull":
    28  		cmd := &RemotePullCommand{Meta: c.Meta}
    29  		return cmd.Run(args[1:])
    30  	case "push":
    31  		cmd := &RemotePushCommand{Meta: c.Meta}
    32  		return cmd.Run(args[1:])
    33  	default:
    34  		c.Ui.Error(c.Help())
    35  		return 1
    36  	}
    37  }
    38  
    39  func (c *RemoteCommand) Help() string {
    40  	helpText := `
    41  Usage: terraform remote <subcommand> [options]
    42  
    43    Configure remote state storage with Terraform.
    44  
    45  Available subcommands:
    46  
    47    config      Configure the remote storage settings.
    48    pull        Sync the remote storage by downloading to local storage.
    49    push        Sync the remote storage by uploading the local storage.
    50  
    51  `
    52  	return strings.TrimSpace(helpText)
    53  }
    54  
    55  func (c *RemoteCommand) Synopsis() string {
    56  	return "Configure remote state storage"
    57  }