Skip to content

Commit

Permalink
style: AssetsFileSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
2637309949 committed Aug 6, 2021
1 parent 4a23bd4 commit 13ac841
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
30 changes: 0 additions & 30 deletions cmd/assert/main.go

This file was deleted.

29 changes: 29 additions & 0 deletions cmd/dolphin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/2637309949/dolphin/cmd/dolphin/template/dist"
"github.com/2637309949/dolphin/cmd/dolphin/utils"
"github.com/gin-gonic/gin"
"github.com/shurcooL/vfsgen"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -25,6 +26,9 @@ import (
_ "github.com/go-sql-driver/mysql"
// "github.com/lib/pq" init
_ "github.com/lib/pq"
// "github.com/mattn/go-sqlite3" init
_ "github.com/mattn/go-sqlite3"

"golang.org/x/sys/unix"
"golang.org/x/term"
)
Expand Down Expand Up @@ -122,6 +126,9 @@ var (
Use: "dolphin",
Long: `Code generation tool for golang`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if cmd.Use == "assert" || cmd.Use == "new" || cmd.Use == "clean" {
return
}
InitViper(cmd, args)
},
CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
Expand Down Expand Up @@ -234,6 +241,27 @@ var (
return nil
},
}
assert = &cobra.Command{
Use: "assert",
Short: "",
RunE: func(_ *cobra.Command, _ []string) error {
if err := os.MkdirAll("../dist", os.ModePerm); err != nil {
if err != nil {
return err
}
}
err := vfsgen.Generate(http.Dir("./"), vfsgen.Options{
Filename: "../dist/assets.go",
PackageName: "dist",
BuildTags: "!dev",
VariableName: "Assets",
})
if err != nil {
return err
}
return nil
},
}
)

func main() {
Expand All @@ -243,6 +271,7 @@ func main() {
rootCmd.AddCommand(more)
rootCmd.AddCommand(clean)
rootCmd.AddCommand(serve)
rootCmd.AddCommand(assert)
if err := rootCmd.Execute(); err != nil {
logrus.Fatal(err)
}
Expand Down

0 comments on commit 13ac841

Please sign in to comment.