2021-04-10 02:01:41 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-04-11 02:14:45 +00:00
|
|
|
"flag"
|
2021-04-10 02:01:41 +00:00
|
|
|
"fmt"
|
2021-04-11 02:14:45 +00:00
|
|
|
"os"
|
2021-04-10 02:01:41 +00:00
|
|
|
|
2021-04-11 02:22:06 +00:00
|
|
|
"git.yetaga.in/alazyreader/libyear/pkg/gomod"
|
|
|
|
"git.yetaga.in/alazyreader/libyear/pkg/libyear"
|
|
|
|
"git.yetaga.in/alazyreader/libyear/pkg/logger"
|
2021-04-10 02:01:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-04-11 02:14:45 +00:00
|
|
|
quiet := flag.Bool("q", false, "quiet; reduces logging and outputs only out-of-date dependencies")
|
|
|
|
verbose := flag.Bool("v", false, "verbose; outputs diagnostic information")
|
|
|
|
indirect := flag.Bool("indirect", false, "include indirect dependencies in calculation (off by default)")
|
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
l := logger.NewLogger(*quiet, *verbose, os.Stdout, os.Stderr)
|
|
|
|
|
|
|
|
g := gomod.GoMod{
|
|
|
|
IncludeIndirect: *indirect,
|
|
|
|
ProxyLoader: gomod.Queryer{Logger: l},
|
|
|
|
Logger: l,
|
|
|
|
}
|
|
|
|
|
|
|
|
pairs, err := g.LoadAndComputePairs("go.mod")
|
2021-04-10 02:01:41 +00:00
|
|
|
|
|
|
|
if err != nil {
|
2021-04-11 02:14:45 +00:00
|
|
|
l.Error(err)
|
|
|
|
os.Exit(255)
|
2021-04-10 02:01:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for dep := range pairs {
|
2021-04-11 02:14:45 +00:00
|
|
|
if pairs[dep].Current.Time == pairs[dep].Latest.Time {
|
|
|
|
if !*quiet {
|
|
|
|
fmt.Printf(
|
|
|
|
"%s: %s year(s) (up to date: %s)\n",
|
|
|
|
pairs[dep].Name,
|
|
|
|
libyear.DecimalYear(libyear.Calc(pairs[dep])),
|
|
|
|
pairs[dep].Latest.Version,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fmt.Printf(
|
|
|
|
"%s: %s year(s) (current: %s, newest: %s)\n",
|
|
|
|
pairs[dep].Name,
|
|
|
|
libyear.DecimalYear(libyear.Calc(pairs[dep])),
|
|
|
|
pairs[dep].Current.Version,
|
|
|
|
pairs[dep].Latest.Version,
|
|
|
|
)
|
|
|
|
}
|
2021-04-10 02:01:41 +00:00
|
|
|
}
|
2021-04-11 02:14:45 +00:00
|
|
|
fmt.Printf("total libyear count: %s year(s)\n", libyear.DecimalYear(libyear.Calc(pairs...)))
|
2021-04-10 02:01:41 +00:00
|
|
|
}
|