Fix version printing to pass vagrant-spec
* Makes all help output showup on stdout like in rubyland * Moves verbosity flags to capital Vs to get out of the way of version * Passes version down to mitchellh/cli so it handles -v and --version flags * Tweaks version output to remove the leading `v` which is not output in legacy vagrant
This commit is contained in:
parent
61c652c28a
commit
736e080add
@ -97,6 +97,10 @@ func Main(args []string) int {
|
||||
Autocomplete: true,
|
||||
AutocompleteNoDefaultFlags: true,
|
||||
HelpFunc: GroupedHelpFunc(cli.BasicHelpFunc(cliName)),
|
||||
// Write help to stdout to match Ruby vagrant behavior
|
||||
HelpWriter: os.Stdout,
|
||||
// Need to set Version on the CLI to enable `-v` and `--version` handling
|
||||
Version: vsn.FullVersionNumber(true),
|
||||
}
|
||||
|
||||
// Run the CLI
|
||||
@ -253,22 +257,22 @@ func logger(args []string) ([]string, hclog.Logger, io.Writer, error) {
|
||||
}
|
||||
|
||||
switch arg {
|
||||
case "-v":
|
||||
case "-V":
|
||||
if level == hclog.NoLevel || level > hclog.Info {
|
||||
level = hclog.Info
|
||||
_ = os.Setenv("VAGRANT_LOG", "info")
|
||||
}
|
||||
case "-vv":
|
||||
case "-VV":
|
||||
if level == hclog.NoLevel || level > hclog.Debug {
|
||||
level = hclog.Debug
|
||||
_ = os.Setenv("VAGRANT_LOG", "debug")
|
||||
}
|
||||
case "-vvv":
|
||||
case "-VVV":
|
||||
if level == hclog.NoLevel || level > hclog.Trace {
|
||||
level = hclog.Trace
|
||||
_ = os.Setenv("VAGRANT_LOG", "trace")
|
||||
}
|
||||
case "-vvvv":
|
||||
case "-VVVV":
|
||||
if level == hclog.NoLevel || level > hclog.Trace {
|
||||
level = hclog.Trace
|
||||
_ = os.Setenv("VAGRANT_LOG", "trace")
|
||||
|
||||
@ -3,6 +3,7 @@ package version
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -30,9 +31,13 @@ func GetVersion() *VersionInfo {
|
||||
md := VersionMetadata
|
||||
desc := GitDescribe
|
||||
if desc != "" {
|
||||
ver = desc
|
||||
// git describe is based off tags which always start with v, but
|
||||
// Vagrant has always reported its version number w/o a leading v in
|
||||
// the CLI, so we'll remove it here
|
||||
re := regexp.MustCompile(`^v`)
|
||||
ver = re.ReplaceAllString(desc, "")
|
||||
} else {
|
||||
ver = fmt.Sprintf("v%s", ver)
|
||||
ver = fmt.Sprintf("%s", ver)
|
||||
}
|
||||
if desc == "" && rel == "" && VersionPrerelease != "" {
|
||||
rel = "dev"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user