Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
51 lines
1.3 KiB
Markdown
51 lines
1.3 KiB
Markdown
---
|
|
sidebar_position: 7
|
|
title: Chain Command Builder (chaincmd)
|
|
slug: /packages/chaincmd
|
|
---
|
|
|
|
# Chain Command Builder (chaincmd)
|
|
|
|
The `chaincmd` package builds `step.Option` command definitions for Cosmos SDK daemon binaries (`simd`, `gaiad`, and others). It does not execute commands directly.
|
|
|
|
For full API details, see the
|
|
[`chaincmd` Go package documentation](https://pkg.go.dev/github.com/ignite/cli/v29/ignite/pkg/chaincmd).
|
|
|
|
## When to use
|
|
|
|
- Build consistent daemon command lines from typed options.
|
|
- Reuse command composition across services and tests.
|
|
- Keep chain binary-specific flags centralized.
|
|
|
|
## Key APIs
|
|
|
|
- `New(appCmd string, options ...Option) ChainCmd`
|
|
- `WithHome(home string) Option`
|
|
- `WithChainID(chainID string) Option`
|
|
- `InitCommand(moniker string, options ...string) step.Option`
|
|
- `BankSendCommand(fromAddress, toAddress, amount string, options ...BankSendOption) step.Option`
|
|
|
|
## Example
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ignite/cli/v29/ignite/pkg/chaincmd"
|
|
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step"
|
|
)
|
|
|
|
func main() {
|
|
cmd := chaincmd.New(
|
|
"simd",
|
|
chaincmd.WithHome("./.simapp"),
|
|
chaincmd.WithChainID("demo-1"),
|
|
)
|
|
|
|
initStep := step.New(cmd.InitCommand("validator"))
|
|
fmt.Println(initStep.Exec.Command)
|
|
fmt.Println(initStep.Exec.Args)
|
|
}
|
|
```
|