Skip to content

Commit

Permalink
Best version yet
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Jan 24, 2025
1 parent 456b240 commit c594390
Show file tree
Hide file tree
Showing 13 changed files with 523 additions and 279 deletions.
11 changes: 6 additions & 5 deletions app/action_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ func (k *KhedraApp) initAction(c *cli.Context) error {
}

steps := []wizard.Screen{
wizard.AddScreen(getWelcomeScreen(k.config)),
wizard.AddScreen(getGeneralScreen(k.config)),
wizard.AddScreen(getServicesScreen(k.config)),
wizard.AddScreen(getChainsScreen(k.config)),
wizard.AddScreen(getSummaryScreen(k.config)),
wizard.AddScreen(getWelcomeScreen()),
wizard.AddScreen(getGeneralScreen()),
wizard.AddScreen(getServicesScreen()),
wizard.AddScreen(getChainsScreen()),
wizard.AddScreen(getLoggingScreen()),
wizard.AddScreen(getSummaryScreen()),
}

reloadConfig := func(string) (any, error) {
Expand Down
61 changes: 34 additions & 27 deletions app/action_init_chains.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package app

import (
"strings"

"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/colors"
"github.com/TrueBlocks/trueblocks-khedra/v2/app/wizard"
"github.com/TrueBlocks/trueblocks-khedra/v2/pkg/types"
)

// screen|---------|---------|---------|---------|---------|---------|---|74
func getChainsScreen(cfg *types.Config) wizard.Screen {
_ = cfg // linter // linter
var chainsTitle = `Chain Settings`
var chainsSubtitle = ``
var chainsInstructions = `Type your answers and press enter. ("b"=back, "q"=quit)`
var chainsBody = `
func getChainsScreen() wizard.Screen {
cTitle := `Chain Settings`
cSubtitle := ``
cInstructions := `Type your answers and press enter. ("b"=back, "q"=quit)`
cBody := `
Khedra will index any number of EVM chains, however it requires an
RPC endpoint for each to do so. Fast, dedicated local endpoints are
preferred. Likely, you will get rate limited if you point to a remote
Expand All @@ -25,33 +21,44 @@ You may add chains to the list by typing the chain's name. Remove chains
with "remove <chain>". Or, an easier way is to edit the configuration
file directly by typing "edit". The mainnet chain is required.
`
var chainsReplacements = []wizard.Replacement{
{Color: colors.Yellow, Values: []string{chainsTitle}},
{Color: colors.Green, Values: []string{"remove <chain>", "Sleep", "mainnet", "\"edit\""}},
}

var chainsQuestions = []wizard.Question{chainsQ0, chainsQ1}
for i := 0; i < len(chainsQuestions); i++ {
chainsQuestions[i].Value = strings.ReplaceAll(chainsQuestions[i].Value, "{cfg.ChainList}", cfg.ChainList())
cReplacements := []wizard.Replacement{
{Color: colors.Yellow, Values: []string{cTitle}},
{Color: colors.Green, Values: []string{
"remove <chain>", "Sleep", "mainnet", "\"edit\"",
}},
}
cQuestions := []wizard.Question{c0, c1}
cStyle := wizard.NewStyle()

return wizard.Screen{
Title: chainsTitle,
Subtitle: chainsSubtitle,
Body: chainsBody,
Instructions: chainsInstructions,
Replacements: chainsReplacements,
Questions: chainsQuestions,
Style: wizard.NewStyle(),
Title: cTitle,
Subtitle: cSubtitle,
Body: cBody,
Instructions: cInstructions,
Replacements: cReplacements,
Questions: cQuestions,
Style: cStyle,
}
}

// --------------------------------------------------------
var chainsQ0 = wizard.Question{}
func cPrepare(key, input string, q *wizard.Question) (string, error) {
return input, nil
}

// --------------------------------------------------------
func cValidate(key string, input string, q *wizard.Question) (string, error) {
return input, nil
}

// --------------------------------------------------------
var c0 = wizard.Question{
//.....question-|---------|---------|---------|---------|---------|----|65
}

var chainsQ1 = wizard.Question{
// --------------------------------------------------------
var c1 = wizard.Question{
//.....question-|---------|---------|---------|---------|---------|----|65
Question: `Which chains do you want to index? (Enter a chain's name
|directly to add chains or "remove <chain>" to remove them.)`,
Value: "{cfg.ChainList}",
}
Loading

0 comments on commit c594390

Please sign in to comment.