6
6
"os/exec"
7
7
"path/filepath"
8
8
"runtime"
9
+ "sort"
9
10
"strings"
10
11
"time"
11
12
@@ -61,7 +62,7 @@ func (m *RunL1NodeNetworkSelect) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
61
62
case Mainnet , Testnet :
62
63
return NewRunL1NodeMonikerInput (m .state ), cmd
63
64
case Local :
64
- return NewRunL1NodeVersionInput (m .state ), nil
65
+ return NewRunL1NodeVersionSelect (m .state ), nil
65
66
}
66
67
return m , tea .Quit
67
68
}
@@ -73,41 +74,52 @@ func (m *RunL1NodeNetworkSelect) View() string {
73
74
return styles .RenderPrompt ("Which network will your node participate in?" , []string {"network" }, styles .Question ) + m .Selector .View ()
74
75
}
75
76
76
- type RunL1NodeVersionInput struct {
77
- utils.TextInput
77
+ type RunL1NodeVersionSelect struct {
78
+ utils.Selector [ string ]
78
79
state * RunL1NodeState
80
+ versions utils.InitiaVersionWithDownloadURL
79
81
question string
80
82
}
81
83
82
- func NewRunL1NodeVersionInput (state * RunL1NodeState ) * RunL1NodeVersionInput {
83
- return & RunL1NodeVersionInput {
84
- TextInput : utils .NewTextInput (),
85
- state : state ,
86
- question : "Please specify the initiad version" ,
84
+ func NewRunL1NodeVersionSelect (state * RunL1NodeState ) * RunL1NodeVersionSelect {
85
+ versions := utils .ListInitiaReleases ()
86
+ options := make ([]string , 0 , len (versions ))
87
+ for key := range versions {
88
+ options = append (options , key )
89
+ }
90
+ sort .Sort (sort .Reverse (sort .StringSlice (options )))
91
+ return & RunL1NodeVersionSelect {
92
+ Selector : utils.Selector [string ]{
93
+ Options : options ,
94
+ },
95
+ state : state ,
96
+ versions : versions ,
97
+ question : "Which network will your node participate in?" ,
87
98
}
88
99
}
89
100
90
- func (m * RunL1NodeVersionInput ) GetQuestion () string {
101
+ func (m * RunL1NodeVersionSelect ) GetQuestion () string {
91
102
return m .question
92
103
}
93
104
94
- func (m * RunL1NodeVersionInput ) Init () tea.Cmd {
105
+ func (m * RunL1NodeVersionSelect ) Init () tea.Cmd {
95
106
return nil
96
107
}
97
108
98
- func (m * RunL1NodeVersionInput ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
99
- input , cmd , done := m .TextInput .Update (msg )
100
- if done {
101
- m .state .initiadVersion = input .Text
102
- m .state .weave .PreviousResponse += styles .RenderPreviousResponse (styles .DotsSeparator , m .GetQuestion (), []string {"initiad version" }, input .Text )
109
+ func (m * RunL1NodeVersionSelect ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
110
+ selected , cmd := m .Select (msg )
111
+ if selected != nil {
112
+ m .state .initiadVersion = * selected
113
+ m .state .initiadEndpoint = m .versions [* selected ]
114
+ m .state .weave .PreviousResponse += styles .RenderPreviousResponse (styles .DotsSeparator , m .GetQuestion (), []string {"initiad version" }, m .state .initiadVersion )
103
115
return NewRunL1NodeChainIdInput (m .state ), cmd
104
116
}
105
- m . TextInput = input
117
+
106
118
return m , cmd
107
119
}
108
120
109
- func (m * RunL1NodeVersionInput ) View () string {
110
- return m . state . weave . PreviousResponse + styles .RenderPrompt (m . GetQuestion () , []string {"initiad version " }, styles .Question ) + m .TextInput .View ()
121
+ func (m * RunL1NodeVersionSelect ) View () string {
122
+ return styles .RenderPrompt ("Which network will your node participate in?" , []string {"network " }, styles .Question ) + m .Selector .View ()
111
123
}
112
124
113
125
type RunL1NodeChainIdInput struct {
0 commit comments