|
@@ -50,6 +50,10 @@ var managementCommands = []string{
|
|
|
"volume",
|
|
"volume",
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const (
|
|
|
|
|
+ scanCommand = "scan"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
// Track sends the tracking analytics to Docker Desktop
|
|
// Track sends the tracking analytics to Docker Desktop
|
|
|
func Track(context string, args []string, flags *flag.FlagSet) {
|
|
func Track(context string, args []string, flags *flag.FlagSet) {
|
|
|
// Fire and forget, we don't want to slow down the user waiting for DD
|
|
// Fire and forget, we don't want to slow down the user waiting for DD
|
|
@@ -71,16 +75,21 @@ func Track(context string, args []string, flags *flag.FlagSet) {
|
|
|
|
|
|
|
|
func getCommand(args []string, flags *flag.FlagSet) string {
|
|
func getCommand(args []string, flags *flag.FlagSet) string {
|
|
|
command := ""
|
|
command := ""
|
|
|
- args = stripFlags(args, flags)
|
|
|
|
|
|
|
+ strippedArgs := stripFlags(args, flags)
|
|
|
|
|
+
|
|
|
|
|
+ if len(strippedArgs) != 0 {
|
|
|
|
|
+ command = strippedArgs[0]
|
|
|
|
|
+
|
|
|
|
|
+ if command == scanCommand {
|
|
|
|
|
+ return getScanCommand(args)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if len(args) != 0 {
|
|
|
|
|
- command = args[0]
|
|
|
|
|
for {
|
|
for {
|
|
|
- currentCommand := args[0]
|
|
|
|
|
|
|
+ currentCommand := strippedArgs[0]
|
|
|
if contains(managementCommands, currentCommand) {
|
|
if contains(managementCommands, currentCommand) {
|
|
|
- if sub := getSubCommand(args[1:]); sub != "" {
|
|
|
|
|
|
|
+ if sub := getSubCommand(strippedArgs[1:]); sub != "" {
|
|
|
command += " " + sub
|
|
command += " " + sub
|
|
|
- args = args[1:]
|
|
|
|
|
|
|
+ strippedArgs = strippedArgs[1:]
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -91,6 +100,20 @@ func getCommand(args []string, flags *flag.FlagSet) string {
|
|
|
return command
|
|
return command
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func getScanCommand(args []string) string {
|
|
|
|
|
+ command := args[0]
|
|
|
|
|
+
|
|
|
|
|
+ if contains(args, "--auth") {
|
|
|
|
|
+ return command + " auth"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if contains(args, "--version") {
|
|
|
|
|
+ return command + " version"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return command
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func getSubCommand(args []string) string {
|
|
func getSubCommand(args []string) string {
|
|
|
if len(args) != 0 && isArg(args[0]) {
|
|
if len(args) != 0 && isArg(args[0]) {
|
|
|
return args[0]
|
|
return args[0]
|