Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add about command #270

Merged
merged 7 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
b00f marked this conversation as resolved.
Show resolved Hide resolved
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
Loading