Skip to content

Commit

Permalink
update description
Browse files Browse the repository at this point in the history
  • Loading branch information
ad3n committed Jul 15, 2022
1 parent 4c00673 commit 8f4315f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 64 deletions.
101 changes: 52 additions & 49 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

var (
version = "v1.2.13"
version = "v1.2.14"
protocMinVersion = 31900
protocGoMinVersion = 12800
protocGRpcMinVersion = 10200
Expand All @@ -30,20 +30,22 @@ var (
func main() {
file := ""
app := &cli.App{
Name: "Bima Cli",
Name: "Bima cli",
Usage: "Bima Framework Toolkit",
Description: "bima version",
EnableBashCompletion: true,
Commands: []*cli.Command{
{
Name: "create",
Aliases: []string{"new"},
Usage: "bima create <command>",
Name: "create",
Aliases: []string{"new"},
Usage: "Create something with bima",
Description: "bima create <command>",
Subcommands: []*cli.Command{
{
Name: "project",
Aliases: []string{"app"},
Usage: "bima create app <name>",
Description: "Create new application or project",
Description: "bima create app <name>",
Usage: "Create new application or project",
Action: func(cCtx *cli.Context) error {
name := cCtx.Args().First()
if name == "" {
Expand All @@ -58,8 +60,8 @@ func main() {
{
Name: "middleware",
Aliases: []string{"mid"},
Usage: "bima create middleware <name>",
Description: "Create new middleware",
Description: "bima create middleware <name>",
Usage: "Create new middleware",
Action: func(cCtx *cli.Context) error {
name := cCtx.Args().First()
if name == "" {
Expand All @@ -74,8 +76,8 @@ func main() {
{
Name: "driver",
Aliases: []string{"dvr"},
Usage: "bima create driver <name>",
Description: "Create new driver",
Description: "bima create driver <name>",
Usage: "Create new driver",
Action: func(cCtx *cli.Context) error {
name := cCtx.Args().First()
if name == "" {
Expand All @@ -90,8 +92,8 @@ func main() {
{
Name: "adapter",
Aliases: []string{"adp"},
Usage: "bima create adapter <name>",
Description: "Create new adapter",
Description: "bima create adapter <name>",
Usage: "Create new adapter",
Action: func(cCtx *cli.Context) error {
name := cCtx.Args().First()
if name == "" {
Expand All @@ -106,8 +108,8 @@ func main() {
{
Name: "route",
Aliases: []string{"rt"},
Usage: "bima create route <name>",
Description: "Create new route",
Description: "bima create route <name>",
Usage: "Create new route",
Action: func(cCtx *cli.Context) error {
name := cCtx.Args().First()
if name == "" {
Expand All @@ -122,9 +124,10 @@ func main() {
},
},
{
Name: "module",
Aliases: []string{"mod"},
Usage: "module <command>",
Name: "module",
Aliases: []string{"mod"},
Usage: "Create or remove module",
Description: "module <command>",
Subcommands: []*cli.Command{
{
Name: "add",
Expand All @@ -138,8 +141,8 @@ func main() {
},
},
Aliases: []string{"new"},
Usage: "module add <name> [<version> -c <config>]",
Description: "Create new module <name> with <version> using <config> file",
Description: "module add <name> [<version> -c <config>]",
Usage: "Create new module <name> with <version> using <config> file",
Action: func(cCtx *cli.Context) error {
name := cCtx.Args().First()
if name == "" {
Expand All @@ -159,8 +162,8 @@ func main() {
{
Name: "remove",
Aliases: []string{"rm", "rem"},
Usage: "module remove <name>",
Description: "Remove module <name>",
Description: "module remove <name>",
Usage: "Remove module <name>",
Action: func(cCtx *cli.Context) error {
name := cCtx.Args().First()
if name == "" {
Expand All @@ -177,11 +180,11 @@ func main() {
{
Name: "dump",
Aliases: []string{"dmp"},
Usage: "dump",
Description: "Generate service container",
Description: "dump",
Usage: "Dump service container",
Action: func(*cli.Context) error {
progress := spinner.New(spinner.CharSets[spinerIndex], duration)
progress.Suffix = " Generate service container... "
progress.Suffix = " Dumping service container... "
progress.Start()
time.Sleep(1 * time.Second)

Expand All @@ -194,8 +197,8 @@ func main() {
{
Name: "build",
Aliases: []string{"install", "compile"},
Usage: "build <name>",
Description: "Build application to binary",
Description: "build <name>",
Usage: "Build application to binary",
Action: func(cCtx *cli.Context) error {
name := cCtx.Args().First()
if name == "" {
Expand All @@ -216,7 +219,7 @@ func main() {

if err := tool.Call("dump"); err != nil {
progress.Stop()
color.New(color.FgRed).Println("Error update DI container")
color.New(color.FgRed).Println("Error updating services container")

return err
}
Expand All @@ -230,8 +233,8 @@ func main() {
{
Name: "update",
Aliases: []string{"upd"},
Usage: "update",
Description: "Update project dependencies",
Description: "update",
Usage: "Update project dependencies",
Action: func(*cli.Context) error {
progress := spinner.New(spinner.CharSets[spinerIndex], duration)
progress.Suffix = " Updating dependencies... "
Expand All @@ -245,7 +248,7 @@ func main() {

if err := tool.Call("dump"); err != nil {
progress.Stop()
color.New(color.FgRed).Println("Error update DI container")
color.New(color.FgRed).Println("Error updating services container")

return err
}
Expand All @@ -258,8 +261,8 @@ func main() {
{
Name: "clean",
Aliases: []string{"cln"},
Usage: "clean",
Description: "Cleaning project dependencies",
Description: "clean",
Usage: "Cleaning project dependencies",
Action: func(*cli.Context) error {
progress := spinner.New(spinner.CharSets[spinerIndex], duration)
progress.Suffix = " Cleaning dependencies... "
Expand All @@ -273,7 +276,7 @@ func main() {

if err := tool.Call("dump"); err != nil {
progress.Stop()
color.New(color.FgRed).Println("Error update DI container")
color.New(color.FgRed).Println("Error updating services container")

return err
}
Expand All @@ -286,11 +289,11 @@ func main() {
{
Name: "generate",
Aliases: []string{"gen", "genproto"},
Usage: "generate",
Description: "Generate code from protobuf file(s)",
Description: "generate",
Usage: "Generate code from protobuf file(s)",
Action: func(*cli.Context) error {
progress := spinner.New(spinner.CharSets[spinerIndex], duration)
progress.Suffix = " Generating protobuff... "
progress.Suffix = " Generating codes from protobuff file(s)... "
progress.Start()
if err := tool.Call("genproto"); err != nil {
progress.Stop()
Expand All @@ -308,7 +311,7 @@ func main() {

if err := tool.Call("dump"); err != nil {
progress.Stop()
color.New(color.FgRed).Println("Error update DI container")
color.New(color.FgRed).Println("Error updating services container")

return err
}
Expand All @@ -330,8 +333,8 @@ func main() {
},
},
Aliases: []string{"rn"},
Usage: "run <mode> [-c <config>]",
Description: "Run application using <config> file",
Description: "run <mode> [-c <config>]",
Usage: "Run application using <config> file",
Action: func(cCtx *cli.Context) error {
mode := cCtx.Args().First()
if mode == "debug" {
Expand Down Expand Up @@ -359,7 +362,7 @@ func main() {
progress.Start()
if err := tool.Call("dump"); err != nil {
progress.Stop()
color.New(color.FgRed).Println("Error update DI container")
color.New(color.FgRed).Println("Error updating services container")

return err
}
Expand All @@ -372,8 +375,8 @@ func main() {
{
Name: "debug",
Aliases: []string{"dbg"},
Usage: "debug",
Description: "Debug application",
Description: "debug",
Usage: "Debug application, your application must running in debug mode",
Action: func(cCtx *cli.Context) error {
content, err := os.ReadFile(".pid")
if err != nil {
Expand All @@ -395,8 +398,8 @@ func main() {
{
Name: "version",
Aliases: []string{"v"},
Usage: "version",
Description: "Show Bima Cli version and Framework",
Description: "version",
Usage: "Show cli and framework version",
Action: func(*cli.Context) error {
wd, _ := os.Getwd()
var path strings.Builder
Expand Down Expand Up @@ -438,17 +441,17 @@ func main() {
{
Name: "upgrade",
Aliases: []string{"upg"},
Usage: "upgrade",
Description: "Upgrade Bima Cli to latest version",
Description: "upgrade",
Usage: "Upgrade cli to latest version",
Action: func(*cli.Context) error {
return tool.Call("upgrade", version)
},
},
{
Name: "makesure",
Aliases: []string{"mks"},
Usage: "makesure",
Description: "Check and install toolchain",
Description: "makesure",
Usage: "Check and install toolchain when it possible",
Action: func(ctx *cli.Context) error {
return tool.Call("makesure", protocMinVersion, protocGoMinVersion, protocGRpcMinVersion)
},
Expand Down
10 changes: 5 additions & 5 deletions tool/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type (

func (m Module) Create(file string, version string) error {
if err := Call("dump"); err != nil {
color.New(color.FgRed).Println("Error update DI container")
color.New(color.FgRed).Println("Error updating services container")

return err
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func (m Module) Create(file string, version string) error {
}

if err = Call("genproto"); err != nil {
color.New(color.FgRed).Println("Error generate code from proto files")
color.New(color.FgRed).Println("Error generate codes from proto files")
_ = m.Remove()

return err
Expand All @@ -84,7 +84,7 @@ func (m Module) Create(file string, version string) error {
}

if err = Call("dump"); err != nil {
color.New(color.FgRed).Println("Error update DI container")
color.New(color.FgRed).Println("Error updating services container")
_ = m.Remove()

return err
Expand All @@ -103,7 +103,7 @@ func (m Module) Create(file string, version string) error {
func (m Module) Remove() error {
remove(string(m))
if err := Call("dump"); err != nil {
color.New(color.FgRed).Println("Error update DI container")
color.New(color.FgRed).Println("Error updating services container")

return err
}
Expand Down Expand Up @@ -224,7 +224,7 @@ func create(factory *generator.Factory, util *color.Color, name string) error {
field := generator.FieldTemplate{}
mapType := utils.NewType()

util.Println("Welcome to Bima Skeleton Module Generator")
util.Println("Welcome to Bima Module Generator")
module.Name = name

index := 2
Expand Down
20 changes: 10 additions & 10 deletions tool/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ func (u util) Upgrade(version string) error {

if latest == version {
progress.Stop()
color.New(color.FgGreen).Println("Bima Cli is already up to date")
color.New(color.FgGreen).Println("Bima cli is already up to date")

return nil
}

progress.Stop()

progress = spinner.New(spinner.CharSets[spinerIndex], duration)
progress.Suffix = " Updating Bima Cli... "
progress.Suffix = " Updating Bima cli... "
progress.Start()

cmd := exec.Command("git", "fetch")
Expand Down Expand Up @@ -290,7 +290,7 @@ func (u util) Upgrade(version string) error {

binPath := os.Getenv("GOBIN")
if binPath == "" {
binPath = os.Getenv("GOPATH")
binPath = fmt.Sprintf("%s/bin", os.Getenv("GOPATH"))
}

if binPath == "" {
Expand All @@ -301,10 +301,10 @@ func (u util) Upgrade(version string) error {
return err
}

binPath = filepath.Dir(string(output))
binPath = strings.TrimSuffix(filepath.Dir(string(output)), "/")
}

cmd = exec.Command("mv", "bima", fmt.Sprintf("%s/bin/bima", binPath))
cmd = exec.Command("mv", "bima", fmt.Sprintf("%s/bima", binPath))
cmd.Dir = wd
output, err = cmd.CombinedOutput()
if err != nil {
Expand All @@ -315,7 +315,7 @@ func (u util) Upgrade(version string) error {
}

progress.Stop()
color.New(color.FgGreen).Print("Bima Cli is upgraded to ")
color.New(color.FgGreen).Print("Bima cli is upgraded to ")
color.New(color.FgGreen, color.Bold).Println(latest)

return nil
Expand Down Expand Up @@ -355,10 +355,10 @@ func (u util) Genproto() error {

func (u util) toolchain() error {
return command(`go install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
`).run()
}

Expand Down

0 comments on commit 8f4315f

Please sign in to comment.