Skip to content

Commit

Permalink
feat: add about command (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
MHSaeedkia authored Jan 15, 2025
1 parent 121ef8f commit c0640ac
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 11 deletions.
6 changes: 6 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ Now, you can interact with Pagu:
calculate reward --stake=1000 --days=1
```

Check the verson of Pagu:

```bash
about
```

## Contributing

We are excited to welcome contributions to Pagu! To get started, follow these steps:
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"os"
"strings"

"github.com/pagu-project/pagu"
pagucmd "github.com/pagu-project/pagu/cmd"
"github.com/pagu-project/pagu/config"
"github.com/pagu-project/pagu/internal/engine"
"github.com/pagu-project/pagu/internal/entity"
"github.com/pagu-project/pagu/internal/version"
"github.com/pagu-project/pagu/pkg/log"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -52,7 +52,7 @@ func run(cmd *cobra.Command, _ []string) {
func main() {
rootCmd := &cobra.Command{
Use: "pagu-cli",
Version: pagu.StringVersion(),
Version: version.StringVersion(),
Run: run,
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/discord/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"github.com/pagu-project/pagu"
"github.com/pagu-project/pagu/cmd"
"github.com/pagu-project/pagu/internal/version"
"github.com/spf13/cobra"
)

Expand All @@ -11,7 +11,7 @@ var configPath string
func main() {
rootCmd := &cobra.Command{
Use: "pagu-discord",
Version: pagu.StringVersion(),
Version: version.StringVersion(),
}

rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "./config.yml", "config path ./config.yml")
Expand Down
4 changes: 2 additions & 2 deletions cmd/grpc/main.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package main

import (
"github.com/pagu-project/pagu"
"github.com/pagu-project/pagu/cmd"
"github.com/pagu-project/pagu/internal/version"
"github.com/spf13/cobra"
)

func main() {
rootCmd := &cobra.Command{
Use: "pagu-grpc",
Version: pagu.StringVersion(),
Version: version.StringVersion(),
}

runCommand(rootCmd)
Expand Down
4 changes: 2 additions & 2 deletions cmd/http/main.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package main

import (
"github.com/pagu-project/pagu"
"github.com/pagu-project/pagu/cmd"
"github.com/pagu-project/pagu/internal/version"
"github.com/spf13/cobra"
)

func main() {
rootCmd := &cobra.Command{
Use: "pagu-http",
Version: pagu.StringVersion(),
Version: version.StringVersion(),
}

runCommand(rootCmd)
Expand Down
4 changes: 2 additions & 2 deletions cmd/telegram/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"github.com/pagu-project/pagu"
"github.com/pagu-project/pagu/cmd"
"github.com/pagu-project/pagu/internal/version"
"github.com/spf13/cobra"
)

Expand All @@ -11,7 +11,7 @@ var configPath string
func main() {
rootCmd := &cobra.Command{
Use: "pagu-telegram",
Version: pagu.StringVersion(),
Version: version.StringVersion(),
}

rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "./config.yml", "config path ./config.yml")
Expand Down
1 change: 1 addition & 0 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Use the following command to create the network:
docker network create pagu_network
```


### Deployment Overview

The deployment system operates as follows:
Expand Down
22 changes: 22 additions & 0 deletions internal/engine/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/pagu-project/pagu/internal/entity"
"github.com/pagu-project/pagu/internal/version"
"github.com/pagu-project/pagu/pkg/utils"
)

Expand All @@ -20,6 +21,11 @@ const errorTemplate = `
{{.err}}
`

const aboutTemplate = `
**About pagu**
version : {{.version}}
`

var (
TargetMaskMainnet = 1
TargetMaskTestnet = 2
Expand Down Expand Up @@ -260,3 +266,19 @@ func (cmd *Command) AddHelpSubCommand() {

cmd.AddSubCommand(helpCmd)
}

func (cmd *Command) AddAboutSubCommand() {
cmd.ResultTemplate = aboutTemplate
aboutCmd := &Command{
Name: "about",
Help: "About Pagu",
AppIDs: entity.AllAppIDs(),
TargetFlag: TargetMaskAll,
ResultTemplate: aboutTemplate,
Handler: func(_ *entity.User, _ *Command, _ map[string]string) CommandResult {
return cmd.RenderResultTemplate("version", version.StringVersion())
},
}

cmd.AddSubCommand(aboutCmd)
}
1 change: 1 addition & 0 deletions internal/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func newBotEngine(ctx context.Context,
rootCmd.AddSubCommand(marketCmd.GetCommand())
rootCmd.AddSubCommand(phoenixCmd.GetCommand())

rootCmd.AddAboutSubCommand()
rootCmd.AddHelpSubCommand()

return &BotEngine{
Expand Down
2 changes: 1 addition & 1 deletion version.go → internal/version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pagu
package version

import "fmt"

Expand Down

0 comments on commit c0640ac

Please sign in to comment.