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

Commit

Permalink
one liner run function for main package in app/build-tool/prebuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
imantung committed Oct 14, 2019
1 parent f8be5bc commit 14c46fb
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package application

import (
log "github.com/sirupsen/logrus"

"os"

"github.com/typical-go/typical-rest-server/EXPERIMENTAL/typictx"
"github.com/typical-go/typical-rest-server/EXPERIMENTAL/typienv"
"github.com/urfave/cli"
)

// Cli return the command line interface
func Cli(c *typictx.Context) *cli.App {
// Run the application
func Run(c *typictx.Context) {
app := cli.NewApp()
app.Name = c.Name
app.Usage = ""
Expand All @@ -25,5 +29,8 @@ func Cli(c *typictx.Context) *cli.App {
Action: cmd.ActionFunc.CommandFunction(c),
})
}
return app
err := app.Run(os.Args)
if err != nil {
log.Fatal(err.Error())
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package buildtool

import (
"os"

log "github.com/sirupsen/logrus"

"github.com/typical-go/typical-rest-server/EXPERIMENTAL/typictx"
"github.com/urfave/cli"
)

// Cli return the command line interface
func Cli(c *typictx.Context) *cli.App {
// Run the build tool
func Run(c *typictx.Context) {
app := cli.NewApp()
app.Name = c.Name
app.Usage = ""
Expand All @@ -18,5 +22,8 @@ func Cli(c *typictx.Context) *cli.App {
for _, cmd := range commands(c) {
app.Commands = append(app.Commands, cmd.CliCommand(c))
}
return app
err := app.Run(os.Args)
if err != nil {
log.Fatal(err.Error())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const (
debugEnv = "PREBUILDER_DEBUG"
)

// Prebuild process
func Prebuild(ctx *typictx.Context) {
// Run the prebuilder
func Run(ctx *typictx.Context) {
if os.Getenv(debugEnv) != "" {
log.SetLevel(log.DebugLevel)
}
Expand Down
9 changes: 1 addition & 8 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package main

import (
"os"

log "github.com/sirupsen/logrus"

"github.com/typical-go/typical-rest-server/EXPERIMENTAL/typicmd/application"
_ "github.com/typical-go/typical-rest-server/cmd/internal/dependency"
"github.com/typical-go/typical-rest-server/typical"
)

func main() {
err := application.Cli(typical.Context).Run(os.Args)
if err != nil {
log.Fatal(err)
}
application.Run(typical.Context)
}
8 changes: 1 addition & 7 deletions cmd/build-tool/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package main

import (
"os"

log "github.com/sirupsen/logrus"
"github.com/typical-go/typical-rest-server/EXPERIMENTAL/typicmd/buildtool"
_ "github.com/typical-go/typical-rest-server/cmd/internal/dependency"
"github.com/typical-go/typical-rest-server/typical"
)

func main() {
err := buildtool.Cli(typical.Context).Run(os.Args)
if err != nil {
log.Fatalf("%s", err.Error())
}
buildtool.Run(typical.Context)
}
2 changes: 1 addition & 1 deletion cmd/pre-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import (
)

func main() {
prebuilder.Prebuild(typical.Context)
prebuilder.Run(typical.Context)
}

0 comments on commit 14c46fb

Please sign in to comment.