Skip to content

Commit 16c4c2f

Browse files
committed
fix:统一参数解析
1 parent e1991c8 commit 16c4c2f

File tree

3 files changed

+55
-12
lines changed

3 files changed

+55
-12
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,18 @@ Usage: goecs [options]
190190
Enable/Disable CPU test (default true)
191191
-cpum string
192192
Set CPU test method (supported: sysbench, geekbench, winsat) (default "sysbench")
193+
-cpu-method string
194+
Set CPU test method (supported: sysbench, geekbench, winsat) (default "sysbench")
193195
-cput string
194196
Set CPU test thread mode (supported: single, multi) (default "multi")
197+
-cpu-thread string
198+
Set CPU test thread mode (supported: single, multi) (default "multi")
195199
-disk
196200
Enable/Disable disk test (default true)
197201
-diskm string
198202
Set disk test method (supported: fio, dd, winsat) (default "fio")
203+
-disk-method string
204+
Set disk test method (supported: fio, dd, winsat) (default "fio")
199205
-diskmc
200206
Enable/Disable multiple disk checks, e.g., -diskmc=false
201207
-diskp string
@@ -207,20 +213,28 @@ Usage: goecs [options]
207213
Show help information
208214
-l string
209215
Set language (supported: en, zh) (default "zh")
216+
-lang string
217+
Set language (supported: en, zh) (default "zh")
210218
-log
211219
Enable/Disable logging in the current path
212220
-memory
213221
Enable/Disable memory test (default true)
214222
-memorym string
215223
Set memory test method (supported: stream, sysbench, dd, winsat, auto) (default "stream")
224+
-memory-method string
225+
Set memory test method (supported: stream, sysbench, dd, winsat, auto) (default "stream")
216226
-menu
217227
Enable/Disable menu mode, disable example: -menu=false (default true)
218228
-nt3
219229
Enable/Disable NT3 test (in 'en' language or on windows it always false) (default true)
220230
-nt3loc string
221231
Specify NT3 test location (supported: GZ, SH, BJ, CD, ALL for Guangzhou, Shanghai, Beijing, Chengdu and all) (default "GZ")
232+
-nt3-location string
233+
Specify NT3 test location (supported: GZ, SH, BJ, CD, ALL for Guangzhou, Shanghai, Beijing, Chengdu and all) (default "GZ")
222234
-nt3t string
223235
Set NT3 test type (supported: both, ipv4, ipv6) (default "ipv4")
236+
-nt3-type string
237+
Set NT3 test type (supported: both, ipv4, ipv6) (default "ipv4")
224238
-ping
225239
Enable/Disable ping test
226240
-security
@@ -233,8 +247,6 @@ Usage: goecs [options]
233247
Enable/Disable Telegram DC test
234248
-upload
235249
Enable/Disable upload the result (default true)
236-
-ut
237-
Enable/Disable unlock media test (default true)
238250
-v Display version information
239251
-version
240252
Display version information

README_EN.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,18 @@ Usage: goecs [options]
189189
Enable/Disable CPU test (default true)
190190
-cpum string
191191
Set CPU test method (supported: sysbench, geekbench, winsat) (default "sysbench")
192+
-cpu-method string
193+
Set CPU test method (supported: sysbench, geekbench, winsat) (default "sysbench")
192194
-cput string
193195
Set CPU test thread mode (supported: single, multi) (default "multi")
196+
-cpu-thread string
197+
Set CPU test thread mode (supported: single, multi) (default "multi")
194198
-disk
195199
Enable/Disable disk test (default true)
196200
-diskm string
197201
Set disk test method (supported: fio, dd, winsat) (default "fio")
202+
-disk-method string
203+
Set disk test method (supported: fio, dd, winsat) (default "fio")
198204
-diskmc
199205
Enable/Disable multiple disk checks, e.g., -diskmc=false
200206
-diskp string
@@ -206,20 +212,28 @@ Usage: goecs [options]
206212
Show help information
207213
-l string
208214
Set language (supported: en, zh) (default "zh")
215+
-lang string
216+
Set language (supported: en, zh) (default "zh")
209217
-log
210218
Enable/Disable logging in the current path
211219
-memory
212220
Enable/Disable memory test (default true)
213221
-memorym string
214222
Set memory test method (supported: stream, sysbench, dd, winsat, auto) (default "stream")
223+
-memory-method string
224+
Set memory test method (supported: stream, sysbench, dd, winsat, auto) (default "stream")
215225
-menu
216226
Enable/Disable menu mode, disable example: -menu=false (default true)
217227
-nt3
218228
Enable/Disable NT3 test (in 'en' language or on windows it always false) (default true)
219229
-nt3loc string
220230
Specify NT3 test location (supported: GZ, SH, BJ, CD, ALL for Guangzhou, Shanghai, Beijing, Chengdu and all) (default "GZ")
231+
-nt3-location string
232+
Specify NT3 test location (supported: GZ, SH, BJ, CD, ALL for Guangzhou, Shanghai, Beijing, Chengdu and all) (default "GZ")
221233
-nt3t string
222234
Set NT3 test type (supported: both, ipv4, ipv6) (default "ipv4")
235+
-nt3-type string
236+
Set NT3 test type (supported: both, ipv4, ipv6) (default "ipv4")
223237
-ping
224238
Enable/Disable ping test
225239
-security
@@ -232,8 +246,6 @@ Usage: goecs [options]
232246
Enable/Disable Telegram DC test
233247
-upload
234248
Enable/Disable upload the result (default true)
235-
-ut
236-
Enable/Disable unlock media test (default true)
237249
-v Display version information
238250
-version
239251
Display version information

internal/params/params.go

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,19 @@ func NewConfig(version string) *Config {
5353
return &Config{
5454
EcsVersion: version,
5555
MenuMode: true,
56+
OnlyChinaTest: false,
57+
Input: "",
58+
Choice: "",
59+
ShowVersion: false,
60+
EnableLogger: false,
5661
Language: "zh",
5762
CpuTestMethod: "sysbench",
5863
CpuTestThreadMode: "multi",
5964
MemoryTestMethod: "stream",
6065
DiskTestMethod: "fio",
66+
DiskTestPath: "",
67+
DiskMultiCheck: false,
68+
Nt3CheckType: "ipv4",
6169
SpNum: 2,
6270
Width: 82,
6371
BasicStatus: true,
@@ -70,11 +78,15 @@ func NewConfig(version string) *Config {
7078
BacktraceStatus: true,
7179
Nt3Status: true,
7280
SpeedTestStatus: true,
73-
Nt3Location: "GZ",
74-
Nt3CheckType: "ipv4",
81+
PingTestStatus: false,
82+
TgdcTestStatus: false,
83+
WebTestStatus: false,
7584
AutoChangeDiskMethod: true,
7685
FilePath: "goecs.txt",
7786
EnableUpload: true,
87+
OnlyIpInfoCheck: false,
88+
Help: false,
89+
Finish: false,
7890
UserSetFlags: make(map[string]bool),
7991
GoecsFlag: flag.NewFlagSet("goecs", flag.ContinueOnError),
8092
}
@@ -87,6 +99,7 @@ func (c *Config) ParseFlags(args []string) {
8799
c.GoecsFlag.BoolVar(&c.ShowVersion, "v", false, "Display version information")
88100
c.GoecsFlag.BoolVar(&c.ShowVersion, "version", false, "Display version information")
89101
c.GoecsFlag.BoolVar(&c.MenuMode, "menu", true, "Enable/Disable menu mode, disable example: -menu=false")
102+
c.GoecsFlag.StringVar(&c.Language, "lang", "zh", "Set language (supported: en, zh)")
90103
c.GoecsFlag.StringVar(&c.Language, "l", "zh", "Set language (supported: en, zh)")
91104
c.GoecsFlag.BoolVar(&c.BasicStatus, "basic", true, "Enable/Disable basic test")
92105
c.GoecsFlag.BoolVar(&c.CpuTestStatus, "cpu", true, "Enable/Disable CPU test")
@@ -102,13 +115,19 @@ func (c *Config) ParseFlags(args []string) {
102115
c.GoecsFlag.BoolVar(&c.TgdcTestStatus, "tgdc", false, "Enable/Disable Telegram DC test")
103116
c.GoecsFlag.BoolVar(&c.WebTestStatus, "web", false, "Enable/Disable popular websites test")
104117
c.GoecsFlag.StringVar(&c.CpuTestMethod, "cpum", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)")
118+
c.GoecsFlag.StringVar(&c.CpuTestMethod, "cpu-method", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)")
105119
c.GoecsFlag.StringVar(&c.CpuTestThreadMode, "cput", "multi", "Set CPU test thread mode (supported: single, multi)")
120+
c.GoecsFlag.StringVar(&c.CpuTestThreadMode, "cpu-thread", "multi", "Set CPU test thread mode (supported: single, multi)")
106121
c.GoecsFlag.StringVar(&c.MemoryTestMethod, "memorym", "stream", "Set memory test method (supported: stream, sysbench, dd, winsat, auto)")
122+
c.GoecsFlag.StringVar(&c.MemoryTestMethod, "memory-method", "stream", "Set memory test method (supported: stream, sysbench, dd, winsat, auto)")
107123
c.GoecsFlag.StringVar(&c.DiskTestMethod, "diskm", "fio", "Set disk test method (supported: fio, dd, winsat)")
124+
c.GoecsFlag.StringVar(&c.DiskTestMethod, "disk-method", "fio", "Set disk test method (supported: fio, dd, winsat)")
108125
c.GoecsFlag.StringVar(&c.DiskTestPath, "diskp", "", "Set disk test path, e.g., -diskp /root")
109126
c.GoecsFlag.BoolVar(&c.DiskMultiCheck, "diskmc", false, "Enable/Disable multiple disk checks, e.g., -diskmc=false")
110127
c.GoecsFlag.StringVar(&c.Nt3Location, "nt3loc", "GZ", "Specify NT3 test location (supported: GZ, SH, BJ, CD, ALL for Guangzhou, Shanghai, Beijing, Chengdu and all)")
128+
c.GoecsFlag.StringVar(&c.Nt3Location, "nt3-location", "GZ", "Specify NT3 test location (supported: GZ, SH, BJ, CD, ALL for Guangzhou, Shanghai, Beijing, Chengdu and all)")
111129
c.GoecsFlag.StringVar(&c.Nt3CheckType, "nt3t", "ipv4", "Set NT3 test type (supported: both, ipv4, ipv6)")
130+
c.GoecsFlag.StringVar(&c.Nt3CheckType, "nt3-type", "ipv4", "Set NT3 test type (supported: both, ipv4, ipv6)")
112131
c.GoecsFlag.IntVar(&c.SpNum, "spnum", 2, "Set the number of servers per operator for speed test")
113132
c.GoecsFlag.BoolVar(&c.EnableLogger, "log", false, "Enable/Disable logging in the current path")
114133
c.GoecsFlag.BoolVar(&c.EnableUpload, "upload", true, "Enable/Disable upload the result")
@@ -176,16 +195,16 @@ func (c *Config) SaveUserSetParams() map[string]interface{} {
176195
if c.UserSetFlags["web"] {
177196
saved["web"] = c.WebTestStatus
178197
}
179-
if c.UserSetFlags["cpum"] {
198+
if c.UserSetFlags["cpum"] || c.UserSetFlags["cpu-method"] {
180199
saved["cpum"] = c.CpuTestMethod
181200
}
182-
if c.UserSetFlags["cput"] {
201+
if c.UserSetFlags["cput"] || c.UserSetFlags["cpu-thread"] {
183202
saved["cput"] = c.CpuTestThreadMode
184203
}
185-
if c.UserSetFlags["memorym"] {
204+
if c.UserSetFlags["memorym"] || c.UserSetFlags["memory-method"] {
186205
saved["memorym"] = c.MemoryTestMethod
187206
}
188-
if c.UserSetFlags["diskm"] {
207+
if c.UserSetFlags["diskm"] || c.UserSetFlags["disk-method"] {
189208
saved["diskm"] = c.DiskTestMethod
190209
}
191210
if c.UserSetFlags["diskp"] {
@@ -194,10 +213,10 @@ func (c *Config) SaveUserSetParams() map[string]interface{} {
194213
if c.UserSetFlags["diskmc"] {
195214
saved["diskmc"] = c.DiskMultiCheck
196215
}
197-
if c.UserSetFlags["nt3loc"] {
216+
if c.UserSetFlags["nt3loc"] || c.UserSetFlags["nt3-location"] {
198217
saved["nt3loc"] = c.Nt3Location
199218
}
200-
if c.UserSetFlags["nt3t"] {
219+
if c.UserSetFlags["nt3t"] || c.UserSetFlags["nt3-type"] {
201220
saved["nt3t"] = c.Nt3CheckType
202221
}
203222
if c.UserSetFlags["spnum"] {

0 commit comments

Comments
 (0)