diff --git a/api/iteration.go b/api/iteration.go index 49b833a62..543bda688 100644 --- a/api/iteration.go +++ b/api/iteration.go @@ -3,6 +3,8 @@ package api import ( "errors" "io/ioutil" + "os" + "os/exec" "path/filepath" "strings" ) @@ -17,6 +19,7 @@ var ( type Iteration struct { Key string `json:"key"` Code string `json:"code"` + TestAnalysis string `json:"test_analysis"` Dir string `json:"dir"` Language string `json:"language"` Problem string `json:"problem"` @@ -52,6 +55,17 @@ func NewIteration(dir string, filenames []string) (*Iteration, error) { iter.Language = segments[1] iter.Problem = segments[2] + // Run tests and write to out file + runTestCmd := exec.Command("rake") + testOutfile, _ := os.Create("./test_out.txt") + defer testOutfile.Close() + runTestCmd.Stdout = testOutfile + runTestCmd.Run() + + // add the test out put to iteration + testOutput, _ := ioutil.ReadFile("./test_out.txt") + iter.TestAnalysis = string(testOutput) + for _, filename := range filenames { b, err := ioutil.ReadFile(filename) if err != nil { diff --git a/exercism/main.go b/exercism/main.go index a52999159..043cb9522 100644 --- a/exercism/main.go +++ b/exercism/main.go @@ -16,7 +16,7 @@ const ( // We try to follow Semantic Versioning (http://semver.org), // but with the http://exercism.io app being a prototype, a // lot of things get out of hand. - Version = "2.0.0" + Version = "2.0.0-rc.1" descDebug = "Outputs useful debug information." descConfigure = "Writes config values to a JSON file." @@ -37,6 +37,7 @@ func main() { api.UserAgent = fmt.Sprintf("github.com/exercism/cli v%s (%s/%s)", Version, runtime.GOOS, runtime.GOARCH) app := cli.NewApp() + app.EnableBashCompletion = true app.Name = "exercism" app.Usage = "A command line tool to interact with http://exercism.io" app.Version = Version @@ -95,6 +96,15 @@ func main() { ShortName: "f", Usage: descFetch, Action: cmd.Fetch, + BashComplete: func(c *cli.Context) { + if len(c.Args()) == 0 { + fmt.Println("java node-js ruby python") + } + + if len(c.Args()) == 1{ + fmt.Println("hamming leap bob gigasecond ") + } + }, }, { Name: "restore",