Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func (c *Client) Tracks() ([]*Track, error) {
return payload.Tracks, nil
}

// Skip sends a request to exercism to skip the exercise given language and slug
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, doc comments :)

func (c *Client) Skip(language, slug string) error {
url := fmt.Sprintf("%s/api/v1/iterations/%s/%s/skip?key=%s", c.APIHost, language, slug, c.APIKey)

Expand Down
2 changes: 2 additions & 0 deletions api/iteration.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func NewIteration(dir string, filenames []string) (*Iteration, error) {
return iter, nil
}

// RelativePath returns the iterations relative path
// iter.Dir/iter.Language/iter.Problem/
func (iter *Iteration) RelativePath() string {
return filepath.Join(iter.Dir, iter.Language, iter.Problem) + string(filepath.Separator)
}
Expand Down
118 changes: 71 additions & 47 deletions bin/build-all
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,75 @@ set -e -x
echo "Creating release dir..."
mkdir -p release

echo "Creating darwin/386 binary..."
GOOS=darwin GOARCH=386 go build -o out/exercism exercism/main.go
cd out
tar cvzf ../release/exercism-mac-32bit.tgz exercism
cd ..

echo "Creating darwin/amd64 binary..."
GOOS=darwin GOARCH=amd64 go build -o out/exercism exercism/main.go
cd out
tar cvzf ../release/exercism-mac-64bit.tgz exercism
cd ..

echo "Creating linux/386 binary..."
GOOS=linux GOARCH=386 go build -o out/exercism exercism/main.go
cd out
tar cvzf ../release/exercism-linux-32bit.tgz exercism
cd ..

echo "Creating linux/amd64 binary..."
GOOS=linux GOARCH=amd64 go build -o out/exercism exercism/main.go
cd out
tar cvzf ../release/exercism-linux-64bit.tgz exercism
cd ..

echo "Creating linux/ARMv5 binary..."
GOOS=linux GOARCH=arm GOARM=5 go build -o out/exercism exercism/main.go
cd out
tar cvzf ../release/exercism-linux-arm-v5.tgz exercism
cd ..

echo "Creating linux/ARMv6 binary..."
GOOS=linux GOARCH=arm GOARM=6 go build -o out/exercism exercism/main.go
cd out
tar cvzf ../release/exercism-linux-arm-v6.tgz exercism
cd ..

echo "Creating windows/386 binary..."
GOOS=windows GOARCH=386 go build -o out/exercism.exe exercism/main.go
cd out
zip ../release/exercism-windows-32bit.zip exercism.exe
cd ..

echo "Creating windows/amd64 binary..."
GOOS=windows GOARCH=amd64 go build -o out/exercism.exe exercism/main.go
cd out
zip ../release/exercism-windows-64bit.zip exercism.exe
cd ..
# variables as defined by "go tool nm"
OSVAR=github.com/exercism/cli/cmd.BuildOS
ARCHVAR=github.com/exercism/cli/cmd.BuildARCH
ARMVAR=github.com/exercism/cli/cmd.BuildARM

createRelease() {
os=$1
arch=$2
arm=$3

if [ "$os" = darwin ]
then
osname='mac'
else
osname=$os
fi
if [ "$arch" = amd64 ]
then
osarch=64bit
else
osarch=32bit
fi

ldflags="-X $OSVAR $os -X $ARCHVAR $arch"
if [ "$arm" ]
then
osarch=arm-v$arm
ldflags="$ldflags -X $ARMVAR $arm"
fi

binname=exercism
if [ "$osname" = windows ]
then
binname="$binname.exe"
fi

relname="../release/exercism-$osname-$osarch"
echo "Creating $os/$arch binary..."

if [ "$arm" ]
then
GOOS=$os GOARCH=$arch GOARM=$arm go build -ldflags "$ldflags" -o "out/$binname" exercism/main.go
else
GOOS=$os GOARCH=$arch go build -ldflags "$ldflags" -o "out/$binname" exercism/main.go
fi

cd out

if [ "$osname" = windows ]
then
zip "$relname.zip" "$binname"
else
tar cvzf "$relname.tgz" "$binname"
fi
cd ..
}

# Mac Releases
createRelease darwin 386
createRelease darwin amd64

# Linux Releases
createRelease linux 386
createRelease linux amd64

# ARM Releases
createRelease linux arm 5
createRelease linux arm 6

# Windows Releases
createRelease windows 386
createRelease windows amd64
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole thing is so much nicer!

20 changes: 7 additions & 13 deletions cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,12 @@ import (
"net/http"
"os"
"runtime"
"strings"
"time"

"github.com/codegangsta/cli"
"github.com/exercism/cli/config"
)

type release struct {
Location string `json:"html_url"`
TagName string `json:"tag_name"`
}

func (r *release) Version() string {
return strings.TrimPrefix(r.TagName, "v")
}

// Debug provides information about the user's environment and configuration.
func Debug(ctx *cli.Context) {
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")
Expand All @@ -44,6 +34,10 @@ func Debug(ctx *cli.Context) {
}

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

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

fmt.Printf("API: %s [%s]\n", c.API, pingUrl(client, c.API))
fmt.Printf("XAPI: %s [%s]\n", c.XAPI, pingUrl(client, c.XAPI))
fmt.Printf("API: %s [%s]\n", c.API, pingURL(client, c.API))
fmt.Printf("XAPI: %s [%s]\n", c.XAPI, pingURL(client, c.XAPI))
fmt.Printf("Exercises Directory: %s\n", c.Dir)
}

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

func pingUrl(client http.Client, url string) string {
func pingURL(client http.Client, url string) string {
res, err := client.Get(url)
if err != nil {
return err.Error()
Expand Down
1 change: 1 addition & 0 deletions cmd/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/exercism/cli/config"
)

// Open uses the given language and exercise and opens it in the browser
func Open(ctx *cli.Context) {
c, err := config.New(ctx.GlobalString("config"))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/exercism/cli/config"
)

// Skip command allows a user to skip a specific problem
func Skip(ctx *cli.Context) {
c, err := config.New(ctx.GlobalString("config"))
if err != nil {
Expand Down
Loading