Skip to content

Commit

Permalink
add qol changes (usage & example, error on no dir)
Browse files Browse the repository at this point in the history
  • Loading branch information
apprehensions committed Apr 25, 2024
1 parent 98eb165 commit 2239d28
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions cmd/wholesale/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"os"
"archive/zip"
"bytes"
"errors"
Expand Down Expand Up @@ -28,9 +29,7 @@ var (
)

func init() {
flag.StringVar(&guid, "guid", "", "Roblox deployment GUID to retrieve")
flag.StringVar(&channel, "channel", "LIVE", "Roblox deployment channel for the GUID")
flag.StringVar(&binType, "type", "player", "Roblox BinaryType for the GUID")

}

type BinaryAssembler struct {
Expand Down Expand Up @@ -90,27 +89,32 @@ func (h htmlLogWriter) Write(p []byte) (n int, err error) {

func main() {
log.SetOutput(&htmlLogWriter{outputHTMLName: "log"})
log.SetFlags(0)
guid := flag.String("guid", "", "Roblox deployment GUID to retrieve")
channel := flag.String("channel", "", "Roblox deployment channel for the GUID")
bin := flag.String("type", "WindowsPlayer", "Roblox BinaryType for the GUID")
flag.Parse()

if len(os.Args) < 2 {
log.Fatalf("%s\n%s", "usage: wholesale?guid=guid[&channel=channel][&type=binaryType]",
"example: wholesale?guid=version-1870963560174427&type=WindowsStudio64")
}

var t cs.BinaryType
switch binType {
case "player":
switch *bin {
case "WindowsPlayer":
t = cs.WindowsPlayer
case "studio":
case "WindowsStudio64":
t = cs.WindowsStudio64
default:
log.Fatalf("Unsupported binary type %s, must be one of %s",
binType, []string{"player", "studio"})
}

if guid == "" {
log.Fatalf("GUID required")
log.Fatal("Unsupported binary type", binType,
"must be either WindowsPlayer or WindowsStudio64")
}

d := rbxbin.Deployment{
Type: t,
Channel: channel,
GUID: guid,
Channel: *channel,
GUID: *guid,
}
name := fmt.Sprintf("%s-%s-%s.zip", d.Channel, d.Type, d.GUID)

Expand Down Expand Up @@ -191,7 +195,7 @@ func (ba *BinaryAssembler) Assemble(pkgs []rbxbin.Package, mirror *rbxbin.Mirror

dir, ok := dirs[p.Name]
if !ok {
return errors.New("unhandled package " + p.Name)
log.Fatalf("unhandled package %s, was the correct binary type set?", p.Name)
}
url := ba.m.PackageURL(ba.d, p.Name)

Expand Down

0 comments on commit 2239d28

Please sign in to comment.