Skip to content

Commit 6587eb0

Browse files
committed
Merge pull request #196 from Tonkpils/upgrade
Upgrade command
2 parents 7680fa3 + 6678aa8 commit 6587eb0

8 files changed

Lines changed: 298 additions & 60 deletions

File tree

api/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ func (c *Client) Tracks() ([]*Track, error) {
266266
return payload.Tracks, nil
267267
}
268268

269+
// Skip sends a request to exercism to skip the exercise given language and slug
269270
func (c *Client) Skip(language, slug string) error {
270271
url := fmt.Sprintf("%s/api/v1/iterations/%s/%s/skip?key=%s", c.APIHost, language, slug, c.APIKey)
271272

api/iteration.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ func NewIteration(dir string, filenames []string) (*Iteration, error) {
7373
return iter, nil
7474
}
7575

76+
// RelativePath returns the iterations relative path
77+
// iter.Dir/iter.Language/iter.Problem/
7678
func (iter *Iteration) RelativePath() string {
7779
return filepath.Join(iter.Dir, iter.Language, iter.Problem) + string(filepath.Separator)
7880
}

bin/build-all

Lines changed: 71 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,75 @@ set -e -x
55
echo "Creating release dir..."
66
mkdir -p release
77

8-
echo "Creating darwin/386 binary..."
9-
GOOS=darwin GOARCH=386 go build -o out/exercism exercism/main.go
10-
cd out
11-
tar cvzf ../release/exercism-mac-32bit.tgz exercism
12-
cd ..
13-
14-
echo "Creating darwin/amd64 binary..."
15-
GOOS=darwin GOARCH=amd64 go build -o out/exercism exercism/main.go
16-
cd out
17-
tar cvzf ../release/exercism-mac-64bit.tgz exercism
18-
cd ..
19-
20-
echo "Creating linux/386 binary..."
21-
GOOS=linux GOARCH=386 go build -o out/exercism exercism/main.go
22-
cd out
23-
tar cvzf ../release/exercism-linux-32bit.tgz exercism
24-
cd ..
25-
26-
echo "Creating linux/amd64 binary..."
27-
GOOS=linux GOARCH=amd64 go build -o out/exercism exercism/main.go
28-
cd out
29-
tar cvzf ../release/exercism-linux-64bit.tgz exercism
30-
cd ..
31-
32-
echo "Creating linux/ARMv5 binary..."
33-
GOOS=linux GOARCH=arm GOARM=5 go build -o out/exercism exercism/main.go
34-
cd out
35-
tar cvzf ../release/exercism-linux-arm-v5.tgz exercism
36-
cd ..
37-
38-
echo "Creating linux/ARMv6 binary..."
39-
GOOS=linux GOARCH=arm GOARM=6 go build -o out/exercism exercism/main.go
40-
cd out
41-
tar cvzf ../release/exercism-linux-arm-v6.tgz exercism
42-
cd ..
43-
44-
echo "Creating windows/386 binary..."
45-
GOOS=windows GOARCH=386 go build -o out/exercism.exe exercism/main.go
46-
cd out
47-
zip ../release/exercism-windows-32bit.zip exercism.exe
48-
cd ..
49-
50-
echo "Creating windows/amd64 binary..."
51-
GOOS=windows GOARCH=amd64 go build -o out/exercism.exe exercism/main.go
52-
cd out
53-
zip ../release/exercism-windows-64bit.zip exercism.exe
54-
cd ..
8+
# variables as defined by "go tool nm"
9+
OSVAR=github.com/exercism/cli/cmd.BuildOS
10+
ARCHVAR=github.com/exercism/cli/cmd.BuildARCH
11+
ARMVAR=github.com/exercism/cli/cmd.BuildARM
5512

13+
createRelease() {
14+
os=$1
15+
arch=$2
16+
arm=$3
17+
18+
if [ "$os" = darwin ]
19+
then
20+
osname='mac'
21+
else
22+
osname=$os
23+
fi
24+
if [ "$arch" = amd64 ]
25+
then
26+
osarch=64bit
27+
else
28+
osarch=32bit
29+
fi
30+
31+
ldflags="-X $OSVAR $os -X $ARCHVAR $arch"
32+
if [ "$arm" ]
33+
then
34+
osarch=arm-v$arm
35+
ldflags="$ldflags -X $ARMVAR $arm"
36+
fi
37+
38+
binname=exercism
39+
if [ "$osname" = windows ]
40+
then
41+
binname="$binname.exe"
42+
fi
43+
44+
relname="../release/exercism-$osname-$osarch"
45+
echo "Creating $os/$arch binary..."
46+
47+
if [ "$arm" ]
48+
then
49+
GOOS=$os GOARCH=$arch GOARM=$arm go build -ldflags "$ldflags" -o "out/$binname" exercism/main.go
50+
else
51+
GOOS=$os GOARCH=$arch go build -ldflags "$ldflags" -o "out/$binname" exercism/main.go
52+
fi
53+
54+
cd out
55+
56+
if [ "$osname" = windows ]
57+
then
58+
zip "$relname.zip" "$binname"
59+
else
60+
tar cvzf "$relname.tgz" "$binname"
61+
fi
62+
cd ..
63+
}
64+
65+
# Mac Releases
66+
createRelease darwin 386
67+
createRelease darwin amd64
68+
69+
# Linux Releases
70+
createRelease linux 386
71+
createRelease linux amd64
72+
73+
# ARM Releases
74+
createRelease linux arm 5
75+
createRelease linux arm 6
76+
77+
# Windows Releases
78+
createRelease windows 386
79+
createRelease windows amd64

cmd/debug.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,12 @@ import (
88
"net/http"
99
"os"
1010
"runtime"
11-
"strings"
1211
"time"
1312

1413
"github.com/codegangsta/cli"
1514
"github.com/exercism/cli/config"
1615
)
1716

18-
type release struct {
19-
Location string `json:"html_url"`
20-
TagName string `json:"tag_name"`
21-
}
22-
23-
func (r *release) Version() string {
24-
return strings.TrimPrefix(r.TagName, "v")
25-
}
26-
2717
// Debug provides information about the user's environment and configuration.
2818
func Debug(ctx *cli.Context) {
2919
defer fmt.Printf("\nIf you are having trouble and need to file a GitHub issue (https://github.com/exercism/exercism.io/issues) please include this information (except your API key. Keep that private).\n")
@@ -44,6 +34,10 @@ func Debug(ctx *cli.Context) {
4434
}
4535

4636
fmt.Printf("OS/Architecture: %s/%s\n", runtime.GOOS, runtime.GOARCH)
37+
fmt.Printf("Build OS/Architecture %s/%s\n", BuildOS, BuildARCH)
38+
if BuildARM != "" {
39+
fmt.Printf("Build ARMv%s\n", BuildARM)
40+
}
4741

4842
dir, err := config.Home()
4943
if err != nil {
@@ -73,8 +67,8 @@ func Debug(ctx *cli.Context) {
7367
fmt.Println("API Key: <not configured>")
7468
}
7569

76-
fmt.Printf("API: %s [%s]\n", c.API, pingUrl(client, c.API))
77-
fmt.Printf("XAPI: %s [%s]\n", c.XAPI, pingUrl(client, c.XAPI))
70+
fmt.Printf("API: %s [%s]\n", c.API, pingURL(client, c.API))
71+
fmt.Printf("XAPI: %s [%s]\n", c.XAPI, pingURL(client, c.XAPI))
7872
fmt.Printf("Exercises Directory: %s\n", c.Dir)
7973
}
8074

@@ -92,7 +86,7 @@ func checkLatestRelease(client http.Client) (*release, error) {
9286
return &rel, nil
9387
}
9488

95-
func pingUrl(client http.Client, url string) string {
89+
func pingURL(client http.Client, url string) string {
9690
res, err := client.Get(url)
9791
if err != nil {
9892
return err.Error()

cmd/open.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/exercism/cli/config"
1212
)
1313

14+
// Open uses the given language and exercise and opens it in the browser
1415
func Open(ctx *cli.Context) {
1516
c, err := config.New(ctx.GlobalString("config"))
1617
if err != nil {

cmd/skip.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/exercism/cli/config"
1010
)
1111

12+
// Skip command allows a user to skip a specific problem
1213
func Skip(ctx *cli.Context) {
1314
c, err := config.New(ctx.GlobalString("config"))
1415
if err != nil {

0 commit comments

Comments
 (0)