mirror of
https://github.com/docker/compose.git
synced 2025-07-17 18:54:29 +02:00
Merge pull request #1884 from thaJeztah/dont_trim_version_prefix
Do not strip "v" prefix from version when printing
This commit is contained in:
commit
1da8be257b
@ -57,17 +57,16 @@ func runVersion(cmd *cobra.Command) error {
|
|||||||
var versionString string
|
var versionString string
|
||||||
var err error
|
var err error
|
||||||
format := strings.ToLower(strings.ReplaceAll(cmd.Flag(formatOpt).Value.String(), " ", ""))
|
format := strings.ToLower(strings.ReplaceAll(cmd.Flag(formatOpt).Value.String(), " ", ""))
|
||||||
displayedVersion := strings.TrimPrefix(internal.Version, "v")
|
|
||||||
// Replace is preferred in this case to keep the order.
|
// Replace is preferred in this case to keep the order.
|
||||||
switch format {
|
switch format {
|
||||||
case formatter.PRETTY, "":
|
case formatter.PRETTY, "":
|
||||||
versionString, err = getOutFromMoby(cmd, fixedPrettyArgs(os.Args[1:])...)
|
versionString, err = getOutFromMoby(cmd, fixedPrettyArgs(os.Args[1:])...)
|
||||||
versionString = strings.Replace(versionString,
|
versionString = strings.Replace(versionString,
|
||||||
"\n Version:", "\n Cloud integration: "+displayedVersion+"\n Version:", 1)
|
"\n Version:", "\n Cloud integration: "+internal.Version+"\n Version:", 1)
|
||||||
case formatter.JSON, formatter.TemplateLegacyJSON: // Try to catch full JSON formats
|
case formatter.JSON, formatter.TemplateLegacyJSON: // Try to catch full JSON formats
|
||||||
versionString, err = getOutFromMoby(cmd, fixedJSONArgs(os.Args[1:])...)
|
versionString, err = getOutFromMoby(cmd, fixedJSONArgs(os.Args[1:])...)
|
||||||
versionString = strings.Replace(versionString,
|
versionString = strings.Replace(versionString,
|
||||||
`"Version":`, fmt.Sprintf(`"CloudIntegration":%q,"Version":`, displayedVersion), 1)
|
`"Version":`, fmt.Sprintf(`"CloudIntegration":%q,"Version":`, internal.Version), 1)
|
||||||
default:
|
default:
|
||||||
versionString, err = getOutFromMoby(cmd)
|
versionString, err = getOutFromMoby(cmd)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package compose
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
@ -52,14 +51,13 @@ func versionCommand() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runVersion(opts versionOptions) {
|
func runVersion(opts versionOptions) {
|
||||||
displayedVersion := strings.TrimPrefix(internal.Version, "v")
|
|
||||||
if opts.short {
|
if opts.short {
|
||||||
fmt.Println(displayedVersion)
|
fmt.Println(internal.Version)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if opts.format == formatter.JSON {
|
if opts.format == formatter.JSON {
|
||||||
fmt.Printf(`{"version":"%s"}\n`, displayedVersion)
|
fmt.Printf(`{"version":%q}\n`, internal.Version)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("Docker Compose version %s\n", displayedVersion)
|
fmt.Println("Docker Compose version", internal.Version)
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
dockercli "github.com/docker/cli/cli"
|
dockercli "github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli-plugins/manager"
|
"github.com/docker/cli/cli-plugins/manager"
|
||||||
"github.com/docker/cli/cli-plugins/plugin"
|
"github.com/docker/cli/cli-plugins/plugin"
|
||||||
@ -58,6 +56,6 @@ func main() {
|
|||||||
manager.Metadata{
|
manager.Metadata{
|
||||||
SchemaVersion: "0.1.0",
|
SchemaVersion: "0.1.0",
|
||||||
Vendor: "Docker Inc.",
|
Vendor: "Docker Inc.",
|
||||||
Version: strings.TrimPrefix(internal.Version, "v"),
|
Version: internal.Version,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user