33// Use of this source code is governed by the BSD 3-Clause License.
44// See the LICENSE file for details.
55
6- use cy "colorify"
6+ use cy "jpu/ colorify"
77use "std/flag"
88use "std/os"
99use ss "std/strings"
@@ -12,20 +12,6 @@ use "std/sys"
1212const protonGeURL = "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases"
1313const defaultInstallDir = "~/.steam/root/compatibilitytools.d/"
1414
15- static argMap: map[int][2]str = {}
16- static successMessage = cy::Colorify("#", cy::Style{
17- Foreground: cy::Foreground.Green,
18- Background: cy::Background.Black,
19- })
20- static infoMessage = cy::Colorify("*", cy::Style{
21- Foreground: cy::Foreground.Blue,
22- Background: cy::Background.Black,
23- })
24- static errorMessage = cy::Colorify("!", cy::Style{
25- Foreground: cy::Foreground.Red,
26- Background: cy::Background.Black,
27- })
28-
2915fn main() {
3016 mut fs := flag::FlagSet.New()
3117
@@ -45,29 +31,29 @@ fn main() {
4531 ret
4632 }
4733
48- println(infoMessage + " No arguments provided. Assuming an update.")
34+ printInfo(" No arguments provided. Assuming an update.")
4935 update(dir)
5036}
5137
5238fn update(mut installDir: str) {
53- println(infoMessage + " Getting the latest Proton-GE release...")
39+ printInfo(" Getting the latest Proton-GE release...")
5440 proton := GetProton("", protonGeURL, installDir) else {
5541 handleErr(error)
5642 ret
5743 }
58- println(infoMessage + " Downloading...")
44+ printInfo(" Downloading...")
5945 proton.Download() else {
6046 handleErr(error)
6147 }
62- println(infoMessage + " Installing...")
48+ printInfo(" Installing...")
6349 proton.Install() else {
6450 handleErr(error)
6551 }
66- println(successMessage + " Done!")
52+ printSuccess(" Done!")
6753}
6854
6955fn handleErr(err: any) {
70- print(errorMessage + " " )
56+ printError( )
7157 println(err)
7258 sys::Exit(1)
7359}
@@ -86,4 +72,23 @@ fn autoHelp(mut flags: &flag::FlagSet): (res: str) {
8672 }
8773
8874 ret res
75+ }
76+
77+ fn printSuccess(msg: str) {
78+ println(cy::Colorify("#", cy::Style{
79+ Foreground: cy::Foreground.Green,
80+ Background: cy::Background.Black,
81+ }) + " " + msg)
82+ }
83+ fn printInfo(msg: str) {
84+ println(cy::Colorify("*", cy::Style{
85+ Foreground: cy::Foreground.Blue,
86+ Background: cy::Background.Black,
87+ }) + " " + msg)
88+ }
89+ fn printError() {
90+ println(cy::Colorify("!", cy::Style{
91+ Foreground: cy::Foreground.Red,
92+ Background: cy::Background.Black,
93+ }) + " ")
8994}
0 commit comments