Skip to content

Commit

Permalink
Update version output for -v and --version flags
Browse files Browse the repository at this point in the history
The flags -v and --version are handled by the CLI runner, which
outputs the raw version string. This change shortcuts the handling of
the flags to force Packer to run the version subcommand.

Closes: #12565
  • Loading branch information
nywilken committed Aug 11, 2023
1 parent 19055df commit 7669434
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ func wrappedMain() int {
Ui: ui,
}

//versionCLIHelper shortcuts "--version" and "-v" to just show the version
versionCLIHelper := &cli.CLI{
Args: args,
Version: version.Version,
}
if versionCLIHelper.IsVersion() && versionCLIHelper.Version != "" {
// by default version flags ignore all other args so there is no need to persist the original args.
args = []string{"version"}
}

cli := &cli.CLI{
Args: args,
Autocomplete: true,
Expand Down

0 comments on commit 7669434

Please sign in to comment.