66 "fmt"
77 "net"
88 "net/url"
9- "os"
109 "strconv"
1110 "strings"
1211
@@ -19,9 +18,19 @@ import (
1918// RunQuickstart runs the interactive quickstart wizard using a single-page
2019// tabbed form so that users can review/edit all configuration at once.
2120func RunQuickstart (opt * Options ) error {
21+ if opt == nil {
22+ return fmt .Errorf ("options is required" )
23+ }
24+
25+ configPath := opt .Config
26+ if configPath == "" {
27+ configPath = configs .ServerConfigFileName
28+ opt .Config = configPath
29+ }
30+
2231 // skip if config already exists
23- if _ , err := os . Stat ( opt . Config ); err == nil {
24- logs .Log .Warnf ("config %s already exists, skipping quickstart" , opt . Config )
32+ if existing := configs . FindConfig ( configPath ); existing != "" {
33+ logs .Log .Warnf ("config %s already exists, skipping quickstart" , existing )
2534 return nil
2635 }
2736
@@ -85,7 +94,7 @@ func RunQuickstart(opt *Options) error {
8594 Name : "encryption_key" , Title : "Encryption Key" ,
8695 Kind : wizard .KindInput , InputValue : encryptionKey ,
8796 Required : true ,
88- Value : & encryptionKey ,
97+ Value : & encryptionKey ,
8998 },
9099 },
91100 },
@@ -120,21 +129,21 @@ func RunQuickstart(opt *Options) error {
120129 {
121130 Name : "tcp_port" , Title : "TCP Port" ,
122131 Description : "ignored if tcp not selected" ,
123- Kind : wizard .KindInput , InputValue : tcpPort ,
132+ Kind : wizard .KindInput , InputValue : tcpPort ,
124133 Validate : validatePort ,
125134 Value : & tcpPort ,
126135 },
127136 {
128137 Name : "http_port" , Title : "HTTP Port" ,
129138 Description : "ignored if http not selected" ,
130- Kind : wizard .KindInput , InputValue : httpPort ,
139+ Kind : wizard .KindInput , InputValue : httpPort ,
131140 Validate : validatePort ,
132141 Value : & httpPort ,
133142 },
134143 {
135144 Name : "rem_name" , Title : "REM Pipeline Name" ,
136145 Description : "ignored if rem not selected" ,
137- Kind : wizard .KindInput , InputValue : remName ,
146+ Kind : wizard .KindInput , InputValue : remName ,
138147 Value : & remName ,
139148 },
140149 },
@@ -201,14 +210,14 @@ func RunQuickstart(opt *Options) error {
201210 {
202211 Name : "notify_param1" , Title : "Webhook/Token/APIKey" ,
203212 Description : "main credential for the service" ,
204- Kind : wizard .KindInput , InputValue : notifyParam1 ,
213+ Kind : wizard .KindInput , InputValue : notifyParam1 ,
205214 Required : true ,
206215 Value : & notifyParam1 ,
207216 },
208217 {
209218 Name : "notify_param2" , Title : "Secret/ChatID (optional)" ,
210219 Description : "dingtalk secret or telegram chat ID" ,
211- Kind : wizard .KindInput , InputValue : notifyParam2 ,
220+ Kind : wizard .KindInput , InputValue : notifyParam2 ,
212221 Value : & notifyParam2 ,
213222 },
214223 },
@@ -326,7 +335,7 @@ func RunQuickstart(opt *Options) error {
326335 return fmt .Errorf ("failed to save config: %w" , err )
327336 }
328337
329- logs .Log .Importantf ("quickstart config saved to %s" , opt . Config )
338+ logs .Log .Importantf ("quickstart config saved to %s" , configPath )
330339 return nil
331340}
332341
0 commit comments