mirror of
https://github.com/docker/compose.git
synced 2025-07-25 14:44:29 +02:00
Reorder --help
flag always first in metrics
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
c1fe338ac7
commit
b238232a77
@ -18,7 +18,7 @@ package metrics
|
|||||||
|
|
||||||
var commandFlags = []string{
|
var commandFlags = []string{
|
||||||
//added to catch scan details
|
//added to catch scan details
|
||||||
"--version", "--login", "--help",
|
"--version", "--login",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generated with generatecommands/main.go
|
// Generated with generatecommands/main.go
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/utils"
|
"github.com/docker/compose-cli/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -51,15 +53,15 @@ func GetCommand(args []string) string {
|
|||||||
result := ""
|
result := ""
|
||||||
onlyFlags := false
|
onlyFlags := false
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
|
if arg == "--help" {
|
||||||
|
result = strings.TrimSpace(arg + " " + result)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if arg == "--" {
|
if arg == "--" {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if isCommandFlag(arg) || (!onlyFlags && isCommand(arg)) {
|
if isCommandFlag(arg) || (!onlyFlags && isCommand(arg)) {
|
||||||
if result == "" {
|
result = strings.TrimSpace(result + " " + arg)
|
||||||
result = arg
|
|
||||||
} else {
|
|
||||||
result = result + " " + arg
|
|
||||||
}
|
|
||||||
if isCommand(arg) && !isManagementCommand(arg) {
|
if isCommand(arg) && !isManagementCommand(arg) {
|
||||||
onlyFlags = true
|
onlyFlags = true
|
||||||
}
|
}
|
||||||
|
@ -162,12 +162,12 @@ func TestKeepHelpCommands(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "run with help flag",
|
name: "run with help flag",
|
||||||
args: []string{"run", "--help"},
|
args: []string{"run", "--help"},
|
||||||
expected: "run --help",
|
expected: "--help run",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with help flag before-after commands",
|
name: "with help flag before-after commands",
|
||||||
args: []string{"compose", "--help", "up"},
|
args: []string{"compose", "--help", "up"},
|
||||||
expected: "compose --help up",
|
expected: "--help compose up",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "help flag",
|
name: "help flag",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user