Skip to content

Commit 5d19263

Browse files
committed
Support C#
1 parent 31be6fe commit 5d19263

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

cmd/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var buildCmd = &cobra.Command{
3535
Output: output,
3636
}
3737
switch data.Lang {
38-
case "go", "js", "ts":
38+
case "cs", "go", "js", "ts":
3939
err = modules.ExecuteBuild(buildData, data)
4040
abort(err)
4141
default:

cmd/new.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func newClient() error {
164164
return err
165165
}
166166

167-
language, err := cli.SelectString("Language:", []string{"Go", "JavaScript", "TypeScript"}, []string{"go", "js", "ts"})
167+
language, err := cli.SelectString("Language:", []string{"C#", "Go", "JavaScript", "TypeScript"}, []string{"cs", "go", "js", "ts"})
168168
if err != nil {
169169
return err
170170
}
@@ -187,6 +187,9 @@ func newClient() error {
187187
}
188188

189189
switch language {
190+
case "cs":
191+
newData.LibraryVersion = external.LibraryVersionFromCGVersion("code-game-project", "csharp-client", info.CGVersion)
192+
err = modules.ExecuteNewClient(newData)
190193
case "go":
191194
newData.LibraryVersion = external.LibraryVersionFromCGVersion("code-game-project", "go-client", info.CGVersion)
192195
err = modules.ExecuteNewClient(newData)
@@ -200,11 +203,14 @@ func newClient() error {
200203
return err
201204
}
202205

203-
if language == "go" || language == "ts" {
206+
if language == "cs" || language == "go" || language == "ts" {
204207
eventsOutput := info.Name
205-
if language == "go" {
208+
switch language {
209+
case "cs":
210+
eventsOutput = strings.ReplaceAll(strings.Title(strings.ReplaceAll(strings.ReplaceAll(eventsOutput, "_", " "), "-", " ")), " ", "")
211+
case "go":
206212
eventsOutput = strings.ReplaceAll(strings.ReplaceAll(eventsOutput, "-", ""), "_", "")
207-
} else if language == "ts" {
213+
case "ts":
208214
eventsOutput = filepath.Join("src", eventsOutput)
209215
}
210216
err = cggenevents.CGGenEvents(cgeVersion, eventsOutput, external.BaseURL("http", external.IsTLS(url), url), language)

cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var runCmd = &cobra.Command{
3333
}
3434

3535
switch data.Lang {
36-
case "go", "js", "ts":
36+
case "cs", "go", "js", "ts":
3737
err = modules.ExecuteRun(runData, data)
3838
abort(err)
3939
default:

cmd/update.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func updateClient(config *cgfile.CodeGameFileData) error {
8484
}
8585

8686
switch config.Lang {
87+
case "cs":
88+
updateData.LibraryVersion = external.LibraryVersionFromCGVersion("code-game-project", "csharp-client", info.CGVersion)
89+
err = modules.ExecuteUpdate(updateData, config)
8790
case "go":
8891
updateData.LibraryVersion = external.LibraryVersionFromCGVersion("code-game-project", "go-client", info.CGVersion)
8992
err = modules.ExecuteUpdate(updateData, config)
@@ -97,16 +100,18 @@ func updateClient(config *cgfile.CodeGameFileData) error {
97100
return err
98101
}
99102

100-
if config.Lang == "go" || config.Lang == "ts" {
103+
if config.Lang == "cs" || config.Lang == "go" || config.Lang == "ts" {
101104
eventsOutput := config.Game
102-
if config.Lang == "go" {
105+
switch config.Lang {
106+
case "cs":
107+
eventsOutput = strings.ReplaceAll(strings.Title(strings.ReplaceAll(strings.ReplaceAll(eventsOutput, "_", " "), "-", " ")), " ", "")
108+
case "go":
103109
eventsOutput = strings.ReplaceAll(strings.ReplaceAll(eventsOutput, "-", ""), "_", "")
104-
} else if config.Lang == "ts" {
110+
case "ts":
105111
eventsOutput = filepath.Join("src", eventsOutput)
106112
}
107113
err = cggenevents.CGGenEvents(cgeVersion, eventsOutput, api.BaseURL(), config.Lang)
108114
}
109-
110115
return err
111116
}
112117

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/code-game-project/codegame-cli/cmd"
2121
)
2222

23-
const Version = "0.7.1"
23+
const Version = "0.7.2"
2424

2525
func main() {
2626
checkVersion()

0 commit comments

Comments
 (0)