Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
boilerplate for code gen
Browse files Browse the repository at this point in the history
  • Loading branch information
juliankoehn committed Apr 20, 2020
1 parent f15fc97 commit f66808e
Show file tree
Hide file tree
Showing 6 changed files with 1,258 additions and 0 deletions.
11 changes: 11 additions & 0 deletions enlight/cmd/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cmd

var generateCmd = &cobra.Command{
Use: "generate",
Short: "Generate application components",
Aliases: []string{"g"}
}

func init() {

}
24 changes: 24 additions & 0 deletions enlight/cmd/generate/middleware.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package generate

import "github.com/spf13/cobra"

var (
resourceOptions = struct {
}
)

const middlewareExample = `$ enlight g middleware auth`

// MiddlewareCmd generates a new middleware/middleware file and a stub test.
var MiddlewareCmd = &cobra.Command{
Use: "middleware [name]",
Example: middlewareExample,
Aliases: []string{"m"},
Short: "Generate a new middleware/middleware file",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return fmt.Errof("you must supply a name")
}
return nil
},
}
24 changes: 24 additions & 0 deletions enlight/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"os"

"github.com/spf13/cobra"
)

// RootCmd is the hook for all of the other commands in the enlight binary.
var RootCmd = &cobra.Command{
SilenceErrors: true,
Use: "enlight",
Short: "Build Enlight applications with ease",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}

// Execute adds all child commands to the root command sets flags appropriately.
func Execute() {
if err := RootCmd.Execute(); err != nil {
os.Exit(-1)
}
}
9 changes: 9 additions & 0 deletions enlight/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/juliankoehn/enlight/enlight/cmd"
)

func main() {
cmd.Execute()
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ module github.com/juliankoehn/enlight
go 1.13

require (
github.com/gobuffalo/buffalo v0.16.5 // indirect
github.com/gobuffalo/clara v0.10.1
github.com/json-iterator/go v1.1.9
github.com/klauspost/compress v1.10.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.5.1
github.com/valyala/fasthttp v1.11.0
)
Loading

0 comments on commit f66808e

Please sign in to comment.