You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB
Go

2 years ago
package cli
import (
"fmt"
"github.com/fatih/color"
2 years ago
"github.com/forget-the-bright/grvm/internal/pkg/collector"
2 years ago
"github.com/k0kubun/go-ansi"
"github.com/urfave/cli/v2"
)
func remoteVersionLength(version string) string {
yu := 8 - len(version)
for i := 0; i < yu; i++ {
version += " "
}
return version
}
2 years ago
func remoteVersionLength2(version string) string {
yu := 17 - len(version)
for i := 0; i < yu; i++ {
version += " "
}
return version
}
2 years ago
func listRemote(*cli.Context) (err error) {
use_version := inuse(goroot)
out := ansi.NewAnsiStdout()
2 years ago
collector.Init()
2 years ago
rs := collector.Collector.Items
color.New(color.FgGreen).Fprintf(out, " %s\n", " version info RelaseTime")
2 years ago
for _, v := range rs {
2 years ago
if v.Version == use_version { //strings.Contains(v.SimpleName, version)
color.New(color.FgGreen).Fprintf(out, "* %s\n", remoteVersionLength(v.Version)+" "+
remoteVersionLength2(collector.GetFileNameNoSuffix(v.FileName))+" "+v.ReleaseTime)
2 years ago
} else {
2 years ago
fmt.Fprintf(out, " %s\n", remoteVersionLength(v.Version)+" "+
remoteVersionLength2(collector.GetFileNameNoSuffix(v.FileName))+" "+v.ReleaseTime)
2 years ago
}
}
return nil
}