fix: cmd path

This commit is contained in:
Young Xu 2023-01-01 23:46:41 +08:00
parent 08d0662fe6
commit 601d288682
Signed by: xuthus5
GPG Key ID: A23CF9620CBB55F9
3 changed files with 8 additions and 7 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gitter.top/xuthus5/coco"
)
var (
@ -13,7 +14,7 @@ var (
)
func init() {
rootCmd.AddCommand(cocoUpdate())
rootCmd.AddCommand(coco.Update())
}
func main() {

View File

@ -1,4 +1,4 @@
package main
package coco
type Config struct {
Version string `yaml:"version"`

View File

@ -1,15 +1,15 @@
package main
package coco
import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
gitea_api "gitter.top/coco/components/gitea-api"
giteaApi "gitter.top/coco/components/gitea-api"
"gitter.top/coco/components/runtime"
"gitter.top/coco/components/yaml"
)
func cocoUpdate() *cobra.Command {
func Update() *cobra.Command {
var config Config
var configPath string
return &cobra.Command{
@ -20,7 +20,7 @@ func cocoUpdate() *cobra.Command {
_ = yaml.Read(configPath, &config)
},
Run: func(cmd *cobra.Command, args []string) {
client, err := gitea_api.NewClient("https://gitter.top")
client, err := giteaApi.NewClient("https://gitter.top")
if err != nil {
logrus.Errorf("new gitea api failed: %v", err)
return
@ -36,7 +36,7 @@ func cocoUpdate() *cobra.Command {
}
// exec update
repo := fmt.Sprintf("gitter.top/coco/bootstrap@%s", commitID)
repo := fmt.Sprintf("gitter.top/coco/bootstrap/coco/...@%s", commitID)
if output, err := runtime.Exec("go", "build", "-o", "coco", repo); err != nil {
logrus.Errorf("update coco failed: %v", err)
return