Always use a profile file.

This commit is contained in:
Alexander Andreev 2024-12-17 19:30:06 +04:00
parent e23db23eae
commit 8662153706
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
2 changed files with 16 additions and 25 deletions

View File

@ -36,23 +36,21 @@ func (rc *RunCommand) Run() error {
return err return err
} }
if rc.UseProfile { if util.IsFileExist(path.Join(rc.GameDir, mcclprofile.ProfileFileName)) {
if util.IsFileExist(path.Join(rc.GameDir, mcclprofile.ProfileFileName)) { p, err := mcclprofile.Load(rc.GameDir)
p, err := mcclprofile.Load(rc.GameDir) if err != nil {
if err != nil { return err
return err }
} rc.Username = p.Username
rc.Username = p.Username rc.AuthUuid = p.Uuid
rc.AuthUuid = p.Uuid rc.JavaXmx = p.JavaXmx
rc.JavaXmx = p.JavaXmx } else {
} else { p := mcclprofile.Profile{
p := mcclprofile.Profile{ Username: rc.Username,
Username: rc.Username, Uuid: rc.AuthUuid,
Uuid: rc.AuthUuid, JavaXmx: rc.JavaXmx}
JavaXmx: rc.JavaXmx} if err := p.Store(rc.GameDir); err != nil {
if err := p.Store(rc.GameDir); err != nil { return err
return err
}
} }
} }

View File

@ -3,7 +3,6 @@ package main
import ( import (
"fmt" "fmt"
"mccl/cmd/mccl/commands" "mccl/cmd/mccl/commands"
mcclprofile "mccl/internal/mccl_profile"
"os" "os"
) )
@ -98,11 +97,7 @@ func usage() {
" -U,--uuid UUID\n"+ " -U,--uuid UUID\n"+
" player's account UUID (all zeroes by default)\n"+ " player's account UUID (all zeroes by default)\n"+
" --java-Xmx memory\n"+ " --java-Xmx memory\n"+
" java's -Xmx param, e.g. 4G\n"+ " java's -Xmx param, e.g. 4G")
" --profile\n"+
" load/save username, UUID, and -Xmx from/to a file.\n"+
" Once saved, you can ommit -u,-U and --java-Xmx,\n"+
" since they will be stored in", mcclprofile.ProfileFileName)
} }
type arguments struct { type arguments struct {
@ -203,8 +198,6 @@ func parseArguments(args []string) (parsed arguments, err error) {
} }
parsed.JavaXmx = args[i+1] parsed.JavaXmx = args[i+1]
i++ i++
case "--profile":
parsed.UseProfile = true
default: default:
err = fmt.Errorf("an unknown option %s was provided", args[i]) err = fmt.Errorf("an unknown option %s was provided", args[i])
return return