From 89e7438f0f1c040c8028af0dbbcc9940cff72485 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 4 Mar 2015 16:25:11 -0800 Subject: [PATCH] command/remote --- command/remote.go | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 command/remote.go diff --git a/command/remote.go b/command/remote.go new file mode 100644 index 000000000..3e9e05f1b --- /dev/null +++ b/command/remote.go @@ -0,0 +1,57 @@ +package command + +import ( + "strings" +) + +type RemoteCommand struct { + Meta +} + +func (c *RemoteCommand) Run(argsRaw []string) int { + // Duplicate the args so we can munge them without affecting + // future subcommand invocations which will do the same. + args := make([]string, len(argsRaw)) + copy(args, argsRaw) + args = c.Meta.process(args, false) + + if len(args) == 0 { + c.Ui.Error(c.Help()) + return 1 + } + + switch args[0] { + case "config": + cmd := &RemoteConfigCommand{Meta: c.Meta} + return cmd.Run(args[1:]) + case "pull": + cmd := &RemotePullCommand{Meta: c.Meta} + return cmd.Run(args[1:]) + case "push": + cmd := &RemotePushCommand{Meta: c.Meta} + return cmd.Run(args[1:]) + default: + c.Ui.Error(c.Help()) + return 1 + } +} + +func (c *RemoteCommand) Help() string { + helpText := ` +Usage: terraform remote [options] + + Configure remote state storage with Terraform. + +Available subcommands: + + config Configure the remote storage settings. + pull Sync the remote storage by downloading to local storage. + push Sync the remote storage by uploading the local storage. + +` + return strings.TrimSpace(helpText) +} + +func (c *RemoteCommand) Synopsis() string { + return "Configure remote state storage" +}