mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
command/version: use Meta
This commit is contained in:
parent
3a8606c117
commit
dde0f0f8df
@ -3,24 +3,26 @@ package command
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/mitchellh/cli"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// VersionCommand is a Command implementation prints the version.
|
// VersionCommand is a Command implementation prints the version.
|
||||||
type VersionCommand struct {
|
type VersionCommand struct {
|
||||||
|
Meta
|
||||||
|
|
||||||
Revision string
|
Revision string
|
||||||
Version string
|
Version string
|
||||||
VersionPrerelease string
|
VersionPrerelease string
|
||||||
Ui cli.Ui
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *VersionCommand) Help() string {
|
func (c *VersionCommand) Help() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *VersionCommand) Run(_ []string) int {
|
func (c *VersionCommand) Run(args []string) int {
|
||||||
var versionString bytes.Buffer
|
var versionString bytes.Buffer
|
||||||
|
|
||||||
|
args = c.Meta.process(args)
|
||||||
|
|
||||||
fmt.Fprintf(&versionString, "Terraform v%s", c.Version)
|
fmt.Fprintf(&versionString, "Terraform v%s", c.Version)
|
||||||
if c.VersionPrerelease != "" {
|
if c.VersionPrerelease != "" {
|
||||||
fmt.Fprintf(&versionString, ".%s", c.VersionPrerelease)
|
fmt.Fprintf(&versionString, ".%s", c.VersionPrerelease)
|
||||||
|
@ -71,10 +71,10 @@ func init() {
|
|||||||
|
|
||||||
"version": func() (cli.Command, error) {
|
"version": func() (cli.Command, error) {
|
||||||
return &command.VersionCommand{
|
return &command.VersionCommand{
|
||||||
|
Meta: meta,
|
||||||
Revision: GitCommit,
|
Revision: GitCommit,
|
||||||
Version: Version,
|
Version: Version,
|
||||||
VersionPrerelease: VersionPrerelease,
|
VersionPrerelease: VersionPrerelease,
|
||||||
Ui: Ui,
|
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user