Skip to content

Commit 4a91b16

Browse files
committed
Initial commit
0 parents  commit 4a91b16

File tree

16 files changed

+1617
-0
lines changed

16 files changed

+1617
-0
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
create_release:
10+
name: Create release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
- name: Read info
18+
id: tags
19+
shell: bash
20+
run: |
21+
echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
22+
- name: Create Release
23+
id: create_release
24+
uses: actions/create-release@master
25+
env:
26+
GITHUB_TOKEN: ${{ github.token }}
27+
with:
28+
tag_name: ${{ steps.tags.outputs.tag }}
29+
release_name: ${{ steps.tags.outputs.tag }}
30+
draft: false
31+
prerelease: false
32+
publish_binaries:
33+
name: Release Go Binary
34+
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
goos: [linux, windows, darwin]
38+
goarch: [amd64, arm64]
39+
exclude:
40+
- goarch: arm64
41+
goos: windows
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v3
45+
- name: Read info
46+
id: tags
47+
shell: bash
48+
run: |
49+
echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
50+
- name: Build and Publish
51+
uses: wangyoucao577/go-release-action@v1.28
52+
with:
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
goos: ${{ matrix.goos }}
55+
goarch: ${{ matrix.goarch }}
56+
binary_name: codegame-cs
57+
asset_name: codegame-cli-cs-${{matrix.goos}}-${{matrix.goarch}}
58+
extra_files: LICENSE README.md
59+
release_tag: ${{ steps.tags.outputs.tag }}

LICENSE

Lines changed: 675 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# codegame-cli-cs
2+
3+
The C# module for [codegame-cli](https://github.com/code-game-project/codegame-cli).
4+
5+
**This application is not intended for standalone use and should only ever be run by codegame-cli.**
6+
7+
## License
8+
9+
Copyright (c) 2022 Julian Hofmann
10+
11+
This program is free software: you can redistribute it and/or modify
12+
it under the terms of the GNU General Public License as published by
13+
the Free Software Foundation, either version 3 of the License, or
14+
(at your option) any later version.
15+
16+
This program is distributed in the hope that it will be useful,
17+
but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
GNU General Public License for more details.
20+
21+
You should have received a copy of the GNU General Public License
22+
along with this program. If not, see <http://www.gnu.org/licenses/>.

build.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/code-game-project/go-utils/cgfile"
7+
"github.com/code-game-project/go-utils/modules"
8+
)
9+
10+
func Build() error {
11+
config, err := cgfile.LoadCodeGameFile("")
12+
if err != nil {
13+
return err
14+
}
15+
16+
data, err := modules.ReadCommandConfig[modules.BuildData]()
17+
if err != nil {
18+
return err
19+
}
20+
21+
switch config.Type {
22+
case "client":
23+
return buildClient(config.Game, data.Output, config.URL)
24+
default:
25+
return fmt.Errorf("Unknown project type: %s", config.Type)
26+
}
27+
}
28+
29+
func buildClient(gameName, output, url string) error {
30+
return nil
31+
}

go.mod

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module github.com/code-game-project/codegame-cli-go
2+
3+
go 1.18
4+
5+
require (
6+
github.com/Bananenpro/cli v0.3.0
7+
github.com/code-game-project/go-utils v0.2.11
8+
)
9+
10+
require (
11+
github.com/AlecAivazis/survey/v2 v2.3.5 // indirect
12+
github.com/adrg/xdg v0.4.0 // indirect
13+
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
14+
github.com/mattn/go-colorable v0.1.12 // indirect
15+
github.com/mattn/go-isatty v0.0.14 // indirect
16+
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
17+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
18+
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect
19+
golang.org/x/text v0.3.7 // indirect
20+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
21+
)

go.sum

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
github.com/AlecAivazis/survey/v2 v2.3.5 h1:A8cYupsAZkjaUmhtTYv3sSqc7LO5mp1XDfqe5E/9wRQ=
2+
github.com/AlecAivazis/survey/v2 v2.3.5/go.mod h1:4AuI9b7RjAR+G7v9+C4YSlX/YL3K3cWNXgWXOhllqvI=
3+
github.com/Bananenpro/cli v0.3.0 h1:gQOzc22yv+rePT0nRYva1ccdva3hTGyUwrGdcnXqchU=
4+
github.com/Bananenpro/cli v0.3.0/go.mod h1:JBXpIAXo/D0rlsfgCViQBicjcJY6UWUldmxvKM+ijRc=
5+
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
6+
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
7+
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
8+
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
9+
github.com/code-game-project/go-utils v0.2.11 h1:PhAD+6cPacBuAFcfBEV5oHhzo0R9/N48ZGSpziKOKCE=
10+
github.com/code-game-project/go-utils v0.2.11/go.mod h1:/ws9iYkZCnZvS9g2aqdxKwSnU5AEeI7SE1mbB+x4ggg=
11+
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
12+
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
13+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
14+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
15+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
16+
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
17+
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
18+
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
19+
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
20+
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
21+
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
22+
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
23+
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
24+
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
25+
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
26+
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
27+
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
28+
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
29+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
30+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
31+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
32+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
33+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
34+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
35+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
36+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
37+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
38+
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
39+
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
40+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
41+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
42+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
43+
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
44+
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc=
45+
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
46+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
47+
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
48+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
49+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
50+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
51+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
52+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
53+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
8+
"github.com/Bananenpro/cli"
9+
)
10+
11+
func main() {
12+
if len(os.Args) < 2 {
13+
fmt.Fprintf(os.Stderr, "USAGE: %s <command> [...]\n", os.Args[0])
14+
os.Exit(1)
15+
}
16+
17+
workingDir, err := os.Getwd()
18+
if err != nil {
19+
fmt.Fprintln(os.Stderr, err)
20+
}
21+
projectName := filepath.Base(workingDir)
22+
23+
switch os.Args[1] {
24+
case "new":
25+
if len(os.Args) < 3 {
26+
fmt.Fprintf(os.Stderr, "USAGE: %s new client\n", os.Args[0])
27+
os.Exit(1)
28+
}
29+
switch os.Args[2] {
30+
case "client":
31+
err = CreateNewClient(projectName)
32+
default:
33+
fmt.Fprintln(os.Stderr, "Unknown project type:", os.Args[2])
34+
os.Exit(1)
35+
}
36+
case "update":
37+
err = Update()
38+
case "run":
39+
err = Run()
40+
case "build":
41+
err = Build()
42+
default:
43+
fmt.Fprintln(os.Stderr, "Unknown command:", os.Args[1])
44+
os.Exit(1)
45+
}
46+
if err != nil {
47+
if err != cli.ErrCanceled {
48+
cli.Error(err.Error())
49+
}
50+
os.Exit(1)
51+
}
52+
}

0 commit comments

Comments
 (0)