Skip to content

Commit

Permalink
Enhanced version ls command to fetch versions in new install
Browse files Browse the repository at this point in the history
  • Loading branch information
rajch committed Dec 3, 2021
1 parent 0e39f9b commit 0f74bff
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion internal/pkg/cmd/version/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,34 @@ func versionlsCommand(c *cobra.Command, args []string) error {
quiet, _ := c.Root().PersistentFlags().GetBool("quiet")
if quiet {
versionnames := driver.VersionNames()

// If no versions available, try to update list
if len(versionnames) == 0 {
err := driver.UpdateVersionList()
if err != nil {
return err
}

versionnames = driver.VersionNames()
}

for _, versionname := range versionnames {
fmt.Println(versionname)
}
return nil
}

driverversions := driver.Versions()
// If no versions available, try to update list
if len(driverversions) == 0 {
err := driver.UpdateVersionList()
if err != nil {
return err
}

driverversions = driver.Versions()
}

defaultversion, _ := cli.Default("version")
var versionlsFormatter = cli.NewTableRenderer(
"driverls",
Expand All @@ -66,7 +88,7 @@ func versionlsCommand(c *cobra.Command, args []string) error {
defaultversion,
)

versionlsFormatter.Render(os.Stdout, driver.Versions())
versionlsFormatter.Render(os.Stdout, driverversions)

return nil
}
Expand Down

0 comments on commit 0f74bff

Please sign in to comment.