53 lines
810 B
Go
53 lines
810 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"gitter.top/apps/gomod"
|
|
)
|
|
|
|
var mod *cobra.Command
|
|
|
|
func init() {
|
|
mod = &cobra.Command{
|
|
Use: "gomod",
|
|
Short: "go mod manager",
|
|
}
|
|
mod.AddCommand(all())
|
|
mod.AddCommand(single())
|
|
}
|
|
|
|
func all() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "all",
|
|
Short: "upgrade all go mod",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
gomod.AllModUpgrade()
|
|
},
|
|
}
|
|
}
|
|
|
|
func single() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "one",
|
|
Short: "upgrade go mod from url",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) == 0 {
|
|
fmt.Println("url empty")
|
|
return
|
|
}
|
|
for _, url := range args {
|
|
gomod.SingleModUpgrade(url)
|
|
}
|
|
},
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
if err := mod.Execute(); err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
}
|