diff --git a/glide.yaml b/glide.yaml index 662c3a0..36a1912 100644 --- a/glide.yaml +++ b/glide.yaml @@ -7,3 +7,6 @@ import: - package: gopkg.in/urfave/cli.v2 version: ^1.18.0 - package: gopkg.in/yaml.v2 +- package: github.com/tockins/realize + subpackages: + - realize diff --git a/main.go b/main.go index af7c17f..0a49ce4 100644 --- a/main.go +++ b/main.go @@ -1,55 +1,47 @@ package main import ( - "os" - "gopkg.in/urfave/cli.v2" - "fmt" - "github.com/labstack/echo" - "net/http" - "gopkg.in/yaml.v2" - "github.com/labstack/echo/engine/standard" - "realize" + //"os" + //"gopkg.in/urfave/cli.v2" + "github.com/tockins/realize/realize" ) func main() { - t := realize.Config{App_file:"realize.config.yml"} + t := realize.Config{ + App_file:"realize.config.yaml", + App_version:"1.0", + App_main:[]string{"main.go"}, + } t.Create() - app := &cli.App{ - Name: "realize", - Version: "1.0", - Usage: "A sort of Webpack for Go. Run, build and watch file changes with custom paths", - Commands: []*cli.Command{ - { - Name: "run", - Usage: "Build and watch file changes", - Action: func(c *cli.Context) error { - fmt.Printf("Hello %q", c.String("run")) - return nil - }, - }, - { - Name: "start", - Category: "config", - Usage: "create the initial config file", - }, - }, - Flags: []cli.Flag { - &cli.StringFlag{ - Name: "run", - Value: "main.go", - Usage: "main file of your project", - }, - }, - } - - app.Run(os.Args) - - // web server - e := echo.New() - e.GET("/", func(c echo.Context) error { - return c.String(http.StatusOK, "Hello, World!") - }) - e.Run(standard.New("0.0.0.0:8080")) + //app := &cli.App{ + // Name: "realize", + // Version: "1.0", + // Usage: "A sort of Webpack for Go. Run, build and watch file changes with custom paths", + // Commands: []*cli.Command{ + // { + // Name: "run", + // Usage: "Build and watch file changes", + // Action: func(c *cli.Context) error { + // fmt.Printf("Hello %q", c.String("run")) + // return nil + // }, + // }, + // { + // Name: "start", + // Category: "config", + // Usage: "create the initial config file", + // }, + // }, + // Flags: []cli.Flag { + // &cli.StringFlag{ + // Name: "run", + // Value: "main.go", + // Usage: "main file of your project", + // }, + // }, + //} + // + //app.Run(os.Args) } \ No newline at end of file diff --git a/realize/config.go b/realize/config.go index 0b057ca..ab46e2e 100644 --- a/realize/config.go +++ b/realize/config.go @@ -2,14 +2,15 @@ package realize import ( "os" + "gopkg.in/yaml.v2" ) type Config struct { App_file string - app_main []string - app_version string - app_build bool - app_run struct { + App_main []string + App_version string + App_build bool + App_run struct { before, after, paths, ext []string } } @@ -18,7 +19,13 @@ type Config struct { func (h *Config) Create() bool{ var config = Check(h.App_file) if config[0] == false { - if _, err := os.Create("realize.config.yml"); err == nil { + if w, err := os.Create(h.App_file); err == nil { + y, err := yaml.Marshal(&h) + w.WriteString(string(y)) + if err != nil { + defer panic(err) + } + w.Close() return true }else{ panic(err)