opentofu/command/get.go
Martin Atkins c94a6102df command: Improve consistency of the command short descriptions
The short description of our commands (as shown in the main help output
from "terraform") was previously very inconsistent, using different
tense/mood for different commands. Some of the commands were also using
some terminology choices inconsistent with how we currently talk about
the related ideas in our documentation.

Here I've tried to add some consistency by first rewriting them all in
the imperative mood (except the ones that just are just subcommand
groupings), and tweaking some of the terminology to hopefully gel better
with how we present similar ideas in our recently-updated docs.

While working on this I inevitably spotted some similar inconsistencies
in the longer-form help output of some of the commands. I've not reviewed
all of these for consistency, but I did update some where the wording
was either left inconsstent with the short form changes I'd made or
where the prose stood out to me as particularly inconsistent with our
current usual documentation language style.

All of this is subjective, so I expect we'll continue to tweak these over
time as we continue to develop our documentation writing style based on
user questions and feedback.
2020-10-26 09:55:21 -07:00

83 lines
2.0 KiB
Go

package command
import (
"fmt"
"strings"
"github.com/hashicorp/terraform/tfdiags"
)
// GetCommand is a Command implementation that takes a Terraform
// configuration and downloads all the modules.
type GetCommand struct {
Meta
}
func (c *GetCommand) Run(args []string) int {
var update bool
args = c.Meta.process(args)
cmdFlags := c.Meta.defaultFlagSet("get")
cmdFlags.BoolVar(&update, "update", false, "update")
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
if err := cmdFlags.Parse(args); err != nil {
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
return 1
}
path, err := ModulePath(cmdFlags.Args())
if err != nil {
c.Ui.Error(err.Error())
return 1
}
path = c.normalizePath(path)
diags := getModules(&c.Meta, path, update)
c.showDiagnostics(diags)
if diags.HasErrors() {
return 1
}
return 0
}
func (c *GetCommand) Help() string {
helpText := `
Usage: terraform get [options] PATH
Downloads and installs modules needed for the configuration given by
PATH.
This recursively downloads all modules needed, such as modules
imported by modules imported by the root and so on. If a module is
already downloaded, it will not be redownloaded or checked for updates
unless the -update flag is specified.
Module installation also happens automatically by default as part of
the "terraform init" command, so you should rarely need to run this
command separately.
Options:
-update Check already-downloaded modules for available updates
and install the newest versions available.
-no-color Disable text coloring in the output.
`
return strings.TrimSpace(helpText)
}
func (c *GetCommand) Synopsis() string {
return "Install or upgrade remote Terraform modules"
}
func getModules(m *Meta, path string, upgrade bool) tfdiags.Diagnostics {
hooks := uiModuleInstallHooks{
Ui: m.Ui,
ShowLocalPaths: true,
}
return m.installModules(path, upgrade, hooks)
}