Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit f45332a

Browse files
committed
Added option to list installed tools only
1 parent a98a4aa commit f45332a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

cmd/docker-setup/list.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package main
22

33
import (
4+
"github.com/nicholasdille/docker-setup/pkg/tool"
45
"github.com/spf13/cobra"
56
)
67

8+
var installedOnly bool
9+
710
func initListCmd() {
11+
listCmd.Flags().BoolVar(&installedOnly, "installed", false, "List only installed tools")
12+
813
rootCmd.AddCommand(listCmd)
914
}
1015

@@ -18,7 +23,23 @@ var listCmd = &cobra.Command{
1823
assertMetadataFileExists()
1924
assertMetadataIsLoaded()
2025

21-
tools.List()
26+
if installedOnly {
27+
var installedTools tool.Tools
28+
for index := range tools.Tools {
29+
tools.Tools[index].ReplaceVariables(prefix+"/"+target, arch, altArch)
30+
tools.Tools[index].GetMarkerFileStatus(prefix + "/" + cacheDirectory)
31+
tools.Tools[index].GetBinaryStatus()
32+
tools.Tools[index].GetVersionStatus()
33+
34+
if tools.Tools[index].Status.VersionMatches {
35+
installedTools.Tools = append(installedTools.Tools, tools.Tools[index])
36+
}
37+
}
38+
installedTools.List()
39+
40+
} else {
41+
tools.List()
42+
}
2243

2344
return nil
2445
},

0 commit comments

Comments
 (0)