Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #13 from rightfold/master
Browse files Browse the repository at this point in the history
Add COBOL
  • Loading branch information
prasmussen authored May 21, 2017
2 parents 879950b + fbbc597 commit 24bd5f0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ you want to run is installed and is in PATH.
- bash
- c
- clojure
- cobol
- coffeescript
- cpp
- csharp
Expand Down
22 changes: 22 additions & 0 deletions language/cobol/cobol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cobol

import (
"github.com/prasmussen/glot-code-runner/cmd"
"github.com/prasmussen/glot-code-runner/util"
"path/filepath"
)

func Run(files []string, stdin string) (string, string, error) {
workDir := filepath.Dir(files[0])
binName := "a.out"

sourceFiles := util.FilterByExtension(files, "cob")
args := append([]string{"cobc", "-x", "-o", binName}, sourceFiles...)
stdout, stderr, err := cmd.Run(workDir, args...)
if err != nil {
return stdout, stderr, err
}

binPath := filepath.Join(workDir, binName)
return cmd.RunStdin(workDir, stdin, binPath)
}
2 changes: 2 additions & 0 deletions language/language.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/prasmussen/glot-code-runner/language/bash"
"github.com/prasmussen/glot-code-runner/language/c"
"github.com/prasmussen/glot-code-runner/language/clojure"
"github.com/prasmussen/glot-code-runner/language/cobol"
"github.com/prasmussen/glot-code-runner/language/coffeescript"
"github.com/prasmussen/glot-code-runner/language/cpp"
"github.com/prasmussen/glot-code-runner/language/crystal"
Expand Down Expand Up @@ -46,6 +47,7 @@ var languages = map[string]runFn{
"bash": bash.Run,
"c": c.Run,
"clojure": clojure.Run,
"cobol": cobol.Run,
"coffeescript": coffeescript.Run,
"crystal": crystal.Run,
"csharp": csharp.Run,
Expand Down

0 comments on commit 24bd5f0

Please sign in to comment.