github.com/gobuffalo/buffalo-cli/v2@v2.0.0-alpha.15.0.20200919213536-a7350c8e6799/cli/cmds/build/ifaces.go (about) 1 package build 2 3 import ( 4 "context" 5 "flag" 6 "os/exec" 7 8 "github.com/gobuffalo/plugins" 9 "github.com/gobuffalo/plugins/plugio" 10 "github.com/spf13/pflag" 11 ) 12 13 // Builder is a sub-command of buffalo build. 14 // buffalo build webpack 15 type Builder interface { 16 plugins.Plugin 17 Build(ctx context.Context, root string, args []string) error 18 } 19 20 type BeforeBuilder interface { 21 plugins.Plugin 22 BeforeBuild(ctx context.Context, root string, args []string) error 23 } 24 25 type AfterBuilder interface { 26 plugins.Plugin 27 AfterBuild(ctx context.Context, root string, args []string, err error) error 28 } 29 30 type Flagger interface { 31 plugins.Plugin 32 BuildFlags() []*flag.Flag 33 } 34 35 type Pflagger interface { 36 plugins.Plugin 37 BuildFlags() []*pflag.Flag 38 } 39 40 type Packager interface { 41 plugins.Plugin 42 Package(ctx context.Context, root string, files []string) error 43 } 44 45 type PackFiler interface { 46 plugins.Plugin 47 PackageFiles(ctx context.Context, root string) ([]string, error) 48 } 49 50 type Versioner interface { 51 plugins.Plugin 52 BuildVersion(ctx context.Context, root string) (string, error) 53 } 54 55 type Importer interface { 56 plugins.Plugin 57 BuildImports(ctx context.Context, root string) ([]string, error) 58 } 59 60 type GoBuilder interface { 61 plugins.Plugin 62 // GoBuild will be called to build, and execute, the 63 // presented context and args. 64 // The first plugin to receive this call will be the 65 // only to answer it. 66 GoBuild(ctx context.Context, root string, cmd *exec.Cmd) error 67 } 68 69 type BuildArger interface { 70 plugins.Plugin 71 // GoBuildArgs receives the current list 72 // and returns either the same list, or 73 // a modified version of the arguments. 74 // Implementations are responsible for ensuring 75 // that the arguments returned are "valid" 76 // arguments for the `go build` command. 77 GoBuildArgs(ctx context.Context, root string, args []string) ([]string, error) 78 } 79 80 type Namer interface { 81 Builder 82 CmdName() string 83 } 84 85 type Aliaser interface { 86 Builder 87 CmdAliases() []string 88 } 89 90 type Stdouter = plugio.Outer 91 type Stdiner = plugio.Inner 92 type Stderrer = plugio.Errer