From b15a4059bf6df1c11b97e433a565d9cc900d99dd Mon Sep 17 00:00:00 2001 From: Spotlight Date: Fri, 31 Dec 2021 01:35:25 -0600 Subject: [PATCH] Add coloring to progress output --- go.mod | 1 + go.sum | 2 ++ main.go | 14 ++++++++++---- modify_dol.go | 7 ++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 6212ec5..739cde8 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/OpenShopChannel/WSC-Patcher go 1.17 require ( + github.com/logrusorgru/aurora/v3 v3.0.0 github.com/wii-tools/GoNUSD v0.2.1 github.com/wii-tools/arclib v1.0.0 github.com/wii-tools/wadlib v0.3.0 diff --git a/go.sum b/go.sum index a0db38f..35d237e 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4= +github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= github.com/wii-tools/GoNUSD v0.2.1 h1:HW8vssrEiCdFjiugCx3cTTaPw9nlz1TWxzeCqXKqTnQ= github.com/wii-tools/GoNUSD v0.2.1/go.mod h1:jMYMU5X81Hp0R+bq6/0AxAOijGHXfexaG6dLRilgS2s= github.com/wii-tools/arclib v1.0.0 h1:OAmbL3NDUmlR0wa1VpJhxnKiIRFZz1CC40lTVPUm8Ms= diff --git a/main.go b/main.go index b0c7979..1af8dea 100644 --- a/main.go +++ b/main.go @@ -3,10 +3,12 @@ package main import ( "errors" "fmt" + "github.com/logrusorgru/aurora/v3" "github.com/wii-tools/GoNUSD" "github.com/wii-tools/arclib" "github.com/wii-tools/wadlib" "io/fs" + "io/ioutil" "log" "os" ) @@ -20,6 +22,8 @@ var mainDol []byte // mainArc holds the main ARC - our content at index 2. var mainArc *arclib.ARC +// rootCertificate holds the public certificate, in DER form, to be patched in. +var rootCertificate []byte // filePresent returns whether the specified path is present on disk. func filePresent(path string) bool { @@ -77,7 +81,7 @@ func main() { // Determine whether a certificate authority was provided, or generated previously. if !filePresent("./output/root.cer") { - log.Println("Generating root certificates...") + fmt.Println(aurora.Green("Generating root certificates...")) rootCertificate = createCertificates() } else { rootCertificate, err = ioutil.ReadFile("./output/root.cer") @@ -101,9 +105,11 @@ func main() { originalWad.TMD.AccessRightsFlags = 0x3 // Apply all DOL patches - log.Println("Applying DOL patches...") + fmt.Println(aurora.Green("Applying DOL patches...")) applyDefaultPatches() + ioutil.WriteFile("/Users/spot/Desktop/patched.app", mainDol, 0755) + // Load main ARC arcData, err := originalWad.GetContent(2) check(err) @@ -111,7 +117,7 @@ func main() { check(err) // Generate filter list and certificate store - log.Println("Applying Opera patches...") + fmt.Println(aurora.Green("Applying Opera patches...")) modifyAllowList() generateOperaCertStore() @@ -125,7 +131,7 @@ func main() { output, err := originalWad.GetWAD(wadlib.WADTypeCommon) check(err) - log.Println("Done! Install ./output/patched.wad, sit back, and enjoy.") + fmt.Println(aurora.Green("Done! Install ./output/patched.wad, sit back, and enjoy.")) writeOut("patched.wad", output) } diff --git a/modify_dol.go b/modify_dol.go index 48b4702..74b0fd3 100644 --- a/modify_dol.go +++ b/modify_dol.go @@ -3,7 +3,8 @@ package main import ( "bytes" "errors" - "log" + "fmt" + "github.com/logrusorgru/aurora/v3" ) var ( @@ -35,7 +36,7 @@ type PatchSet []Patch func applyPatch(patch Patch) error { // Print name if present if patch.Name != "" { - log.Println("Applying patch " + patch.Name) + fmt.Println(" + Applying patch", aurora.Cyan(patch.Name)) } // Ensure consistency @@ -63,7 +64,7 @@ func applyPatch(patch Patch) error { // applyPatchSet iterates through all possible patches, noting their name. func applyPatchSet(setName string, set PatchSet) { - log.Printf("Handling patch set \"%s\":", setName) + fmt.Printf("Handling patch set \"%s\":\n", aurora.Yellow(setName)) for _, patch := range set { err := applyPatch(patch)