Skip to content

Commit

Permalink
update substreams init codegen list
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBger committed Aug 23, 2024
1 parent dc4db54 commit d2a7667
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cmd/substreams/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,30 @@ func runSubstreamsInitE(cmd *cobra.Command, args []string) error {
}

var options []huh.Option[*pbconvo.DiscoveryResponse_Generator]

maxLen := 0

genMapping := make(map[string]*pbconvo.DiscoveryResponse_Generator)
for _, gen := range resp.Msg.Generators {
endpoint := ""
if gen.Endpoint != "" {
endpoint = " (" + gen.Endpoint + ")"
}

if len(gen.Id+endpoint) > maxLen {
maxLen = len(gen.Id + endpoint)
}

genMapping[gen.Id+endpoint] = gen
}

for key, gen := range genMapping {
entry := huh.Option[*pbconvo.DiscoveryResponse_Generator]{
Key: fmt.Sprintf("%s%s - %s", gen.Id, endpoint, gen.Title),
Key: fmt.Sprintf("%-*s - %s", maxLen, key, gen.Title),
Value: gen,
}
options = append(options, entry)

}

var codegen *pbconvo.DiscoveryResponse_Generator
Expand Down

0 comments on commit d2a7667

Please sign in to comment.