Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
rename application to appModule in context
Browse files Browse the repository at this point in the history
  • Loading branch information
imantung committed Nov 3, 2019
1 parent 6254a29 commit 9d81ebb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions EXPERIMENTAL/typicmd/application/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func Run(ctx *typictx.Context) {
app.Usage = ""
app.Description = ctx.Description
app.Version = ctx.Release.Version
if runner, ok := ctx.Application.(typiobj.Runner); ok {
if runner, ok := ctx.AppModule.(typiobj.Runner); ok {
app.Action = typicli.Action(ctx, runner.Run())
}
app.Before = typicli.LoadEnvFile
if appCli, ok := ctx.Application.(typictx.AppCLI); ok {
if appCli, ok := ctx.AppModule.(typictx.AppCLI); ok {
app.Commands = appCli.AppCommands(ctx)
}
if err := app.Run(os.Args); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion EXPERIMENTAL/typicmd/buildtool/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func readme(w io.Writer, ctx *typictx.Context) (err error) {
md.H2("Run & Test")
runInstruction(md)
md.H2("Application")
application(md, ctx.Application)
application(md, ctx.AppModule)
md.H2("Modules")
for _, m := range ctx.Modules {
module(md, m)
Expand Down
2 changes: 1 addition & 1 deletion EXPERIMENTAL/typictx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (

// ConfigFields return config list
func ConfigFields(ctx *Context) (fields []typiobj.ConfigField) {
if configurer, ok := ctx.Application.(typiobj.Configurer); ok {
if configurer, ok := ctx.AppModule.(typiobj.Configurer); ok {
fields = append(fields, configurer.Configure().ConfigFields()...)
}
for _, module := range ctx.Modules {
Expand Down
12 changes: 6 additions & 6 deletions EXPERIMENTAL/typictx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Context struct {
Name string
Description string
Root string
Application interface{}
AppModule interface{}
Modules slice.Interfaces
Release Release
TestTargets slice.Strings
Expand All @@ -27,15 +27,15 @@ func (c *Context) Validate() error {
if c.Root == "" {
return invalidContextError("Root can't not empty")
}
if _, ok := c.Application.(typiobj.Runner); !ok {
if _, ok := c.AppModule.(typiobj.Runner); !ok {
return invalidContextError("Application must implement Runner")
}
return nil
}

// BuildCommands return list of command for Build-Tool
func (c *Context) BuildCommands() (cmds []cli.Command) {
if commandliner, ok := c.Application.(typiobj.BuildCLI); ok {
if commandliner, ok := c.AppModule.(typiobj.BuildCLI); ok {
cmds = append(cmds, commandliner.Command())
}
for _, module := range c.Modules {
Expand All @@ -49,7 +49,7 @@ func (c *Context) BuildCommands() (cmds []cli.Command) {
// Provide the dependencies
func (c *Context) Provide() (constructors []interface{}) {
constructors = append(constructors, c.Constructors...)
if provider, ok := c.Application.(typiobj.Provider); ok {
if provider, ok := c.AppModule.(typiobj.Provider); ok {
constructors = append(constructors, provider.Provide()...)
}
for _, module := range c.Modules {
Expand All @@ -62,7 +62,7 @@ func (c *Context) Provide() (constructors []interface{}) {

// Destroy the dependencies
func (c *Context) Destroy() (destructors []interface{}) {
if destroyer, ok := c.Application.(typiobj.Destroyer); ok {
if destroyer, ok := c.AppModule.(typiobj.Destroyer); ok {
destructors = append(destructors, destroyer.Destroy()...)
}
for _, module := range c.Modules {
Expand All @@ -75,7 +75,7 @@ func (c *Context) Destroy() (destructors []interface{}) {

// Prepare the run
func (c *Context) Prepare() (preparations []interface{}) {
if preparer, ok := c.Application.(typiobj.Preparer); ok {
if preparer, ok := c.AppModule.(typiobj.Preparer); ok {
preparations = append(preparations, preparer.Prepare()...)
}
return
Expand Down
2 changes: 1 addition & 1 deletion typical/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var Context = &typictx.Context{
Name: "Typical-RESTful-Server",
Description: "Example of typical and scalable RESTful API Server for Go",
Root: "github.com/typical-go/typical-rest-server",
Application: app.Module(),
AppModule: app.Module(),
Modules: []interface{}{
typserver.Module(),
typpostgres.Module(),
Expand Down

0 comments on commit 9d81ebb

Please sign in to comment.