Skip to content

Commit

Permalink
refactor(pkg): Move code out of main
Browse files Browse the repository at this point in the history
  • Loading branch information
cedws committed Nov 17, 2024
1 parent 58a7767 commit f908afc
Show file tree
Hide file tree
Showing 8 changed files with 530 additions and 507 deletions.
66 changes: 66 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package cmd

import (
"context"
"flag"
"log"
"os"
"runtime"

"github.com/cedws/umbra-launcher/internal/umbra"
)

const (
defaultLoginServer = "login.us.wizard101.com:12000"
defaultPatchServer = "patch.us.wizard101.com:12500"
)

var defaultConcurrencyLimit = runtime.NumCPU()

func Execute() {
var (
dir string
username, password string
loginServerAddr, patchServerAddr string
patchOnly bool
fullPatch bool
)

flag.StringVar(&dir, "dir", "Wizard101", "client directory")

flag.StringVar(&username, "username", "", "login username")
flag.StringVar(&password, "password", "", "login password")

flag.StringVar(&loginServerAddr, "login-server", defaultLoginServer, "login server addr")
flag.StringVar(&patchServerAddr, "patch-server", defaultPatchServer, "patch server addr")

flag.BoolVar(&patchOnly, "patch-only", false, "only patch files without logging in")
flag.BoolVar(&fullPatch, "full", false, "patch all game files")

flag.Parse()

if !patchOnly && (username == "" || password == "") {
flag.Usage()
os.Exit(1)
}

if len(os.Args) != 1 {
flag.Usage()
os.Exit(1)
}

params := umbra.LaunchParams{
Dir: dir,
Username: username,
Password: password,
PatchOnly: patchOnly,
FullPatch: fullPatch,
LoginServerAddr: loginServerAddr,
PatchServerAddr: patchServerAddr,
ConcurrencyLimit: defaultConcurrencyLimit,
}

if err := umbra.Patch(context.Background(), params); err != nil {
log.Fatal(err)
}
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/cedws/umbra-launcher

go 1.23.2

replace github.com/cedws/w101-client-go => ../w101-client-go

require (
github.com/cedws/w101-client-go v0.0.0-20241117141549-1bd3b81e980f
github.com/cedws/w101-proto-go v0.0.0-20241117141803-d54f3d276cee
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
github.com/cedws/w101-client-go v0.0.0-20241117141549-1bd3b81e980f h1:1FIoTN84PNCg+e6y0MM+cUyVIxXrxZQzz/ojY1r+haM=
github.com/cedws/w101-client-go v0.0.0-20241117141549-1bd3b81e980f/go.mod h1:LEEZPLzH2mdzndxQPSwg+7ho+Q1U+raLB6802UUvLzQ=
github.com/cedws/w101-proto-go v0.0.0-20241117141803-d54f3d276cee h1:LYB5DpljfGvJZUi4lbOZfAUATfW5d+kCef/uByRbdQ0=
github.com/cedws/w101-proto-go v0.0.0-20241117141803-d54f3d276cee/go.mod h1:Xkfd1lWc3cwpzAFCK1O5DbyAoUyMl3L17BQT1PWL3Dk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
Loading

0 comments on commit f908afc

Please sign in to comment.