Skip to content

Commit

Permalink
feat: add command explain
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidayat Hamir committed Feb 6, 2024
1 parent 897b2c1 commit a861deb
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ go install github.com/spacetronot-research-team/erago@latest
or you can define your prefered version.

```shell
go install github.com/spacetronot-research-team/erago@v0.0.6
go install github.com/spacetronot-research-team/erago@v0.0.7
```

Or you can download erago binary from release page.
Expand Down Expand Up @@ -56,3 +56,25 @@ cd go-customer && erago create-domain profile
```

New domain will be created in directory `go-customer/internal`.

## Docs

```shell
hidayat@thinkubuntu:~/data-d/erajaya/git-repo/erago$ erago --help
erago is Erajaya CLI generate project.

Usage:
erago [command]

Available Commands:
create-domain create-domain will create new domain with the provided domain name
create-project create-project will create new project with the provided domain name
explain explain will explain code architecture
help Help about any command
version version will print erago version

Flags:
-h, --help help for erago

Use "erago [command] --help" for more information about a command.
```
8 changes: 8 additions & 0 deletions cmd/explain/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package explain

import "github.com/spf13/cobra"

// CLI is cobra command used for create new project.
func CLI(cmd *cobra.Command, args []string) {
Explain()
}
19 changes: 19 additions & 0 deletions cmd/explain/explain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package explain

import "fmt"

func Explain() {
fmt.Println(explainText)
}

var explainText = `
├── cmd/ Initial stage of the application will run.
├── internal/ Core module of the application and contains the implementation of various business logic.
│   ├── controller/ This module is only to gather input (REST/gRPC/console/etc) and pass input as request to service.
│   │   ├── http/
│   │   ├── grpc/
│   ├── service/ This module contain business logic, this module get input request from controller, this module use repository for things related to persistence.
│   ├── repository/ This module only for things related to persistence (CRUD database/redis/etc).
├── go.mod
└── go.sum
`
2 changes: 1 addition & 1 deletion cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package version
import "fmt"

func Version() {
fmt.Println("v0.0.6")
fmt.Println("v0.0.7")
}
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/spacetronot-research-team/erago/cmd/createdomain"
"github.com/spacetronot-research-team/erago/cmd/createproject"
"github.com/spacetronot-research-team/erago/cmd/explain"
"github.com/spacetronot-research-team/erago/cmd/version"
"github.com/spf13/cobra"
)
Expand All @@ -21,6 +22,7 @@ func main() {
rootCmd.AddCommand(getCreateDomainCmd())
rootCmd.AddCommand(getCreateProjectCmd())
rootCmd.AddCommand(getVersionCmd())
rootCmd.AddCommand(getExplainCmd())

if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -59,3 +61,14 @@ func getVersionCmd() *cobra.Command {
}
return versionCmd
}

func getExplainCmd() *cobra.Command {
versionCmd := &cobra.Command{
Use: "explain",
Short: "explain will explain code architecture",
Long: "explain will explain code architecture.",
Args: cobra.MaximumNArgs(0),
Run: explain.CLI,
}
return versionCmd
}

0 comments on commit a861deb

Please sign in to comment.