@@ -86,59 +86,59 @@ func runClient(url string, args []string, runtime string, typescript bool) error
8686 cmdArgs = []string {"serve" , "-n" , "--no-port-switching" , "-p" , "8080" , "." }
8787 }
8888
89- done := make (chan struct {})
90- runWhenUP ("localhost:8080" , func () {
91- pflag .Usage = func () {
92- fmt .Fprintf (os .Stdout , "Usage: %s [options] [command]\n \n " , os .Args [0 ])
93- fmt .Fprintf (os .Stdout , "Options:\n " )
94- pflag .PrintDefaults ()
95- fmt .Fprintf (os .Stdout , "\n Commands:\n " )
96- fmt .Fprintf (os .Stdout , " create [options] <username> Create and join a new game.\n " )
97- fmt .Fprintf (os .Stdout , " join [options] <game_id> <username> [join_secret] Join an existing game.\n " )
98- fmt .Fprintf (os .Stdout , " reconnect [options] <username> Reconnect to a game using a saved session.\n " )
99- fmt .Fprintf (os .Stdout , " spectate [options] [game_id] Spectate a new or existing game.\n " )
100- }
89+ pflag .Usage = func () {
90+ fmt .Fprintf (os .Stdout , "Usage: %s [options] [command]\n \n " , os .Args [0 ])
91+ fmt .Fprintf (os .Stdout , "Options:\n " )
92+ pflag .PrintDefaults ()
93+ fmt .Fprintf (os .Stdout , "\n Commands:\n " )
94+ fmt .Fprintf (os .Stdout , " create [options] <username> Create and join a new game.\n " )
95+ fmt .Fprintf (os .Stdout , " join [options] <game_id> <username> [join_secret] Join an existing game.\n " )
96+ fmt .Fprintf (os .Stdout , " reconnect [options] <username> Reconnect to a game using a saved session.\n " )
97+ fmt .Fprintf (os .Stdout , " spectate [options] [game_id] Spectate a new or existing game.\n " )
98+ }
10199
102- var queryParams string
103- var public bool
104- pflag .BoolVar (& public , "public" , false , "Make the created game protected." )
105- var protected bool
106- pflag .BoolVar (& public , "protected" , false , "Make the created game protected." )
107- pflag .CommandLine .Parse (args )
100+ var queryParams string
101+ var public bool
102+ pflag .BoolVar (& public , "public" , false , "Make the created game protected." )
103+ var protected bool
104+ pflag .BoolVar (& public , "protected" , false , "Make the created game protected." )
105+ pflag .CommandLine .Parse (args )
108106
109- var op string
110- if pflag .NArg () > 0 {
111- op = pflag .Arg (0 )
112- }
107+ var op string
108+ if pflag .NArg () > 0 {
109+ op = pflag .Arg (0 )
110+ }
113111
114- switch op {
115- case "create" , "reconnect" :
116- if pflag .NArg () > 1 {
117- queryParams += "&username=" + pflag .Arg (1 )
118- }
119- case "join" :
120- if pflag .NArg () > 1 {
121- queryParams += "&game_id=" + pflag .Arg (1 )
122- }
123- if pflag .NArg () > 2 {
124- queryParams += "&username=" + pflag .Arg (2 )
125- }
126- if pflag .NArg () > 3 {
127- queryParams += "&join_secret=" + pflag .Arg (3 )
128- }
129- case "spectate" :
130- if pflag .NArg () > 1 {
131- queryParams += "&game_id=" + pflag .Arg (1 )
132- }
112+ switch op {
113+ case "create" , "reconnect" :
114+ if pflag .NArg () > 1 {
115+ queryParams += "&username=" + pflag .Arg (1 )
133116 }
134-
135- if public {
136- queryParams += "&public=true"
117+ case "join" :
118+ if pflag .NArg () > 1 {
119+ queryParams += "&game_id=" + pflag .Arg (1 )
120+ }
121+ if pflag .NArg () > 2 {
122+ queryParams += "&username=" + pflag .Arg (2 )
137123 }
138- if protected {
139- queryParams += "&protected=true"
124+ if pflag . NArg () > 3 {
125+ queryParams += "&join_secret=" + pflag . Arg ( 3 )
140126 }
127+ case "spectate" :
128+ if pflag .NArg () > 1 {
129+ queryParams += "&game_id=" + pflag .Arg (1 )
130+ }
131+ }
141132
133+ if public {
134+ queryParams += "&public=true"
135+ }
136+ if protected {
137+ queryParams += "&protected=true"
138+ }
139+
140+ done := make (chan struct {})
141+ runWhenUP ("localhost:8080" , func () {
142142 cgExec .OpenBrowser (fmt .Sprintf ("http://localhost:8080?game_url=%s&op=%s%s" , url , op , queryParams ))
143143 }, done )
144144
0 commit comments