File: version.go

package info (click to toggle)
vagrant 2.3.7%2Bgit20230731.5fc64cde%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 17,616 kB
  • sloc: ruby: 111,820; sh: 462; makefile: 123; ansic: 34; lisp: 1
file content (61 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package cli

import (
	"github.com/hashicorp/vagrant-plugin-sdk/component"
	"github.com/hashicorp/vagrant/internal/version"
)

type VersionCommand struct {
	*baseCommand

	VersionInfo *version.VersionInfo
}

func (c *VersionCommand) Run(args []string) int {
	flagSet := c.Flags()

	// Initialize. If we fail, we just exit since Init handles the UI.
	if err := c.Init(
		WithArgs(args),
		WithFlags(flagSet),
		WithNoConfig(),
		WithClient(false),
	); err != nil {
		return 1
	}

	out := c.VersionInfo.FullVersionNumber(true)
	c.ui.Output(out)

	return 0
}

func (c *VersionCommand) Flags() component.CommandFlags {
	return c.flagSet(0, nil)
}

func (c *VersionCommand) Primary() bool {
	return true
}

// func (c *VersionCommand) AutocompleteArgs() complete.Predictor {
// 	return complete.PredictNothing
// }

// func (c *VersionCommand) AutocompleteFlags() complete.Flags {
// 	return c.Flags().Completions()
// }

func (c *VersionCommand) Synopsis() string {
	return "Prints the version of this Vagrant CLI"
}

func (c *VersionCommand) Help() string {
	return formatHelp(`
Usage: vagrant version
  Prints the version of this Vagrant CLI.

  There are no arguments or flags to this command. Any additional arguments or
  flags are ignored.
`)
}