@@ -16,7 +16,7 @@ import (
1616
1717const pageSize = 10
1818
19- // model holds the state of the UI
19+ // model holds the state of the UI.
2020type discoverCmdModel struct {
2121 spinner spinner.Model
2222 fetching bool
@@ -28,7 +28,7 @@ type discoverCmdModel struct {
2828 chainRegistry * chains.ChainRegistry
2929}
3030
31- // Messages
31+ // Messages.
3232type fetchDoneMsg struct {
3333 reg * chains.ChainRegistry
3434}
@@ -37,12 +37,12 @@ type fetchErrMsg struct {
3737 err error
3838}
3939
40- // Init initialize Bubble Tea program
40+ // Init initialize Bubble Tea program.
4141func (m * discoverCmdModel ) Init () tea.Cmd {
4242 return tea .Batch (fetchChainsCmd )
4343}
4444
45- // fetchChainsCmd fetch the chains in the background
45+ // fetchChainsCmd fetch the chains in the background.
4646func fetchChainsCmd () tea.Msg {
4747 cr := chains .NewChainRegistry ()
4848 if err := cr .FetchChains (); err != nil {
@@ -51,7 +51,7 @@ func fetchChainsCmd() tea.Msg {
5151 return fetchDoneMsg {cr }
5252}
5353
54- // Update handles messages and updates the model accordingly
54+ // Update handles messages and updates the model accordingly.
5555func (m * discoverCmdModel ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
5656 var cmd tea.Cmd
5757 var totalSize int
@@ -114,7 +114,7 @@ func (m *discoverCmdModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
114114 return m , cmd
115115}
116116
117- // View returns the UI as a string
117+ // View returns the UI as a string.
118118func (m * discoverCmdModel ) View () string {
119119 if m .fetching && m .err == nil {
120120 return fmt .Sprintf ("%s Discovering chains... (press 'q' to quit)\n " , m .spinner .View ())
@@ -139,7 +139,7 @@ func (m *discoverCmdModel) View() string {
139139 end = totalSize
140140 }
141141
142- out := " \033 [K" // clear current line before printing
142+ out := outLine
143143 out += fmt .Sprintf ("Fetched %d chains. Showing %d-%d:\n " , totalSize , start + 1 , end )
144144
145145 // ANSI escape codes for highlighting
@@ -149,7 +149,7 @@ func (m *discoverCmdModel) View() string {
149149 for i , k := range chainsNames [start :end ] {
150150 chain := m .chainRegistry .Chains [k ]
151151
152- out += " \033 [K" // clear current line before printing
152+ out += outLine
153153
154154 // Check if the input corresponds to this line number
155155 if i == m .selectedIndex {
@@ -159,13 +159,13 @@ func (m *discoverCmdModel) View() string {
159159 }
160160 }
161161
162- out += " \033 [K" // clear current line before printing
162+ out += outLine
163163 out += "(press 'n'/'right' for next, 'p'/'left' for prev, 'enter' to init chain, 'q'/'ctrl+c' to quit)\n "
164164 return out
165165}
166166
167- func DiscoverHandler (ctx context.Context , cmd * plugin.ExecutedCommand ) error {
168- s := spinner .NewModel ()
167+ func DiscoverHandler (context.Context , * plugin.ExecutedCommand ) error {
168+ s := spinner .New ()
169169 s .Spinner = spinner .Dot
170170 model := & discoverCmdModel {
171171 spinner : s ,
@@ -177,7 +177,7 @@ func DiscoverHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error {
177177 return err
178178 }
179179
180- // if the user selected a chain, execute the add command
180+ // if the user selected a chain, execute the add command.
181181 if len (model .selectedChain .ChainName ) > 0 {
182182 selectedChain := model .chainRegistry .Chains [model .selectedChain .ChainName ]
183183
0 commit comments