diff --git a/cmd/rbxcompiler/rbxcompiler.go b/cmd/rbxcompiler/rbxcompiler.go index da5bd82..ebc2029 100644 --- a/cmd/rbxcompiler/rbxcompiler.go +++ b/cmd/rbxcompiler/rbxcompiler.go @@ -7,6 +7,7 @@ import ( "math" "os" "time" + "strings" "git.itzana.me/itzaname/go-roblox" "git.itzana.me/itzaname/rbxcompiler/internal/rbxbuilder" @@ -16,6 +17,7 @@ var script = flag.Bool("script", false, "If the target is a script.") var doUpload = flag.Bool("upload", false, "If the model should be uploaded.") var output = flag.String("output", "d", "Output path.") var input = flag.String("input", "", "Input path.") +var cookieFile = flag.String("cookie", "", "Path to file containing roblox cookie") var assetId = flag.Int("asset", 0, "Upload asset ID") var groupId = flag.Int("group", 0, "Group ID") var doGenerate = flag.Bool("generate", false, "If a place file should be dumped") @@ -47,7 +49,25 @@ func build() { } if *doUpload { - rbx, err := roblox.New(os.Getenv("RBXCOOKIE")) + rbxcookie := os.Getenv("RBXCOOKIE") + if rbxcookie == "" { + if cookieFile == nil { + fmt.Printf("No credentials provided\n") + os.Exit(1) + return + } + + data, err := os.ReadFile(*cookieFile) + if err != nil { + fmt.Printf("Failed read cookie file: %s\n", err) + os.Exit(1) + return + } + + rbxcookie = strings.Replace(string(data), "\n", "", -1) + } + + rbx, err := roblox.New(rbxcookie) if err != nil { fmt.Printf("Failed to start roblox api client: %s\n", err) os.Exit(1)