Skip to content

Commit

Permalink
FIX : AddAboutSubCommand function .
Browse files Browse the repository at this point in the history
update install.md and add example about command .
  • Loading branch information
MHSaeedkia committed Jan 15, 2025
1 parent a30a279 commit 3e55f24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 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
5 changes: 0 additions & 5 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ Use the following command to create the network:
docker network create pagu_network
```

Now, you can check the verson of Pagu:

```bash
about
```

### Deployment Overview

Expand Down
26 changes: 8 additions & 18 deletions internal/engine/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const errorTemplate = `

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

var (
Expand Down Expand Up @@ -268,25 +268,15 @@ func (cmd *Command) AddHelpSubCommand() {
}

func (cmd *Command) AddAboutSubCommand() {
msg, _ := cmd.executeTemplate(aboutTemplate, map[string]any{"about": version.StringVersion()})
msg += "\n\nAvailable commands:\n"
for _, sc := range cmd.SubCommands {
msg += fmt.Sprintf("- **%-12s**: %s\n", sc.Name, sc.Help)
}
msg += fmt.Sprintf("- **%-12s**: %s\n", "about", "Information about Pagu")
msg += fmt.Sprintf("- **%-12s**: %s\n", "help", "Help for pagu command")

cmd.ResultTemplate = aboutTemplate
aboutCmd := &Command{
Name: "about",
Help: "Information about Pagu",
AppIDs: entity.AllAppIDs(),
TargetFlag: TargetMaskAll,
Name: "about",
Help: "About Pagu",
AppIDs: entity.AllAppIDs(),
TargetFlag: TargetMaskAll,
ResultTemplate: aboutTemplate,
Handler: func(_ *entity.User, _ *Command, _ map[string]string) CommandResult {
return CommandResult{
Title: fmt.Sprintf("%v %v", "Information about Pagu", "\n"),
Message: msg,
Successful: true,
}
return cmd.RenderResultTemplate("version", version.StringVersion())
},
}

Expand Down

0 comments on commit 3e55f24

Please sign in to comment.