Added back a command handling in parseArguments().
This commit is contained in:
parent
87a787da84
commit
a7cf5b0ec8
@ -134,6 +134,39 @@ func parseArguments(args []string) (parsed arguments, err error) {
|
|||||||
parsed.Uuid = "00000000-0000-0000-0000-000000000000"
|
parsed.Uuid = "00000000-0000-0000-0000-000000000000"
|
||||||
|
|
||||||
for i := 0; i < len(args); i++ {
|
for i := 0; i < len(args); i++ {
|
||||||
|
if args[i][0] != '-' {
|
||||||
|
if parsed.Command != "" {
|
||||||
|
return parsed, fmt.Errorf("there is already a command %s, but a second one (%s) was provided",
|
||||||
|
parsed.Command, args[i])
|
||||||
|
}
|
||||||
|
parsed.Command = args[i]
|
||||||
|
switch parsed.Command {
|
||||||
|
case "i":
|
||||||
|
fallthrough
|
||||||
|
case "install":
|
||||||
|
fallthrough
|
||||||
|
case "r":
|
||||||
|
fallthrough
|
||||||
|
case "run":
|
||||||
|
if i+3 > len(args) || args[i+1][0] == '-' {
|
||||||
|
return parsed, fmt.Errorf("a command %s is missing its version and directory arguments",
|
||||||
|
parsed.Command)
|
||||||
|
}
|
||||||
|
parsed.GameVersion = args[i+1]
|
||||||
|
parsed.Directory = args[i+2]
|
||||||
|
i += 2
|
||||||
|
case "l":
|
||||||
|
fallthrough
|
||||||
|
case "list":
|
||||||
|
if i+1 >= len(args) || args[i+1][0] == '-' {
|
||||||
|
return parsed, fmt.Errorf("a command list is missing its directory argument")
|
||||||
|
}
|
||||||
|
parsed.Directory = args[i+1]
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
switch args[i] {
|
switch args[i] {
|
||||||
case "-v":
|
case "-v":
|
||||||
fallthrough
|
fallthrough
|
||||||
|
Loading…
Reference in New Issue
Block a user