• This repository has been archived on 26/Dec/2020
  • Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Code runner

glot-code-runner

THIS REPO IS DEPRECATED AND HAS BEEN REPLACED BY code-runner

Overview

glot-code-runner is a command line application that reads code as a json payload from stdin – compiles and runs the code – and writes the result as json to stdout.

Prerequisites

glot-code-runner requires that the compiler / interpreter for the languages you want to run is installed and is in PATH.

Supported languages

  • assembly
  • ats
  • bash
  • c
  • clojure
  • cobol
  • coffeescript
  • cpp
  • csharp
  • d
  • elixir
  • elm
  • erlang
  • fsharp
  • golang
  • groovy
  • haskell
  • idris
  • java
  • javascript
  • julia
  • lua
  • nim
  • ocaml
  • perl
  • perl6
  • php
  • python
  • ruby
  • rust
  • scala
  • swift

Input (stdin)

The input is required to be a json object containing the properties language and files. language must be a lowecase string matching one of the supported languages. files must be an array with at least one object containing the properties name and content. name is the name of the file and can include forward slashes to create the file in a subdirectory relative to the base directory. All files are written into the same base directory under the OS's temp dir.

In addition, one may optionally provide the stdin and command properties to provide stdin data to the running code and to run the code with a custom command. See examples below.

Output (stdout)

The output is a json object containing the properties stdout, stderr and error. stdout and stderr is captured from the output of the ran code. error is popuplated if there is a compiler / interpreter error. Note that glot-code-runner will exit with a non-zero code if invalid input is given or if the files cannot be written to disk (permissions, disk space, etc). No json will be written to stdout in those cases. Otherwise the exit code is 0.

Examples

Simple example

Input
{
  "language": "python",
  "files": [
    {
      "name": "main.py",
      "content": "print(42)"
    }
  ]
}
Output
{
  "stdout": "42\n",
  "stderr": "",
  "error": ""
}

Read from stdin

Input
{
  "language": "python",
  "stdin": "42",
  "files": [
    {
      "name": "main.py",
      "content": "print(input('Number from stdin: '))"
    }
  ]
}
Output
{
  "stdout": "Number from stdin: 42\n",
  "stderr": "",
  "error": ""
}

Custom run command

Input
{
  "language": "bash",
  "command": "bash main.sh 42",
  "files": [
    {
      "name": "main.sh",
      "content": "echo Number from arg: $1"
    }
  ]
}
Output
{
  "stdout": "Number from arg: 42\n",
  "stderr": "",
  "error": ""
}

More Repositories

1

gdrive

Google Drive CLI Client
Go
8,973
star
2

chrome-cli

Control Google Chrome from the command line
Objective-C
2,514
star
3

glot-run

API for running code inside docker containers
Erlang
148
star
4

glot-containers

Docker containers for running code
Dockerfile
87
star
5

glot-snippets

API for storing code snippets
Erlang
52
star
6

git-vanity-hash

CLI tool for creating commit hashes with a specific prefix
Rust
41
star
7

gandi-api

Go library for the gandi.net API
Go
23
star
8

orri

A web service for hosting websites
Rust
21
star
9

glot.io

DEPRECATED: Pastebin clone built with AngularJS and CouchDB
JavaScript
19
star
10

re

A command line utility for pattern matching similar to 'grep', but supports capture groups and multiline matches.
Go
16
star
11

glot-cli

Command line tool for interacting with the glot api
Go
10
star
12

gandi

Gandi.net CLI tools
Go
8
star
13

cert

Generate self-signed certificates
Go
5
star
14

spotify-track

CLI tool that prints the currently playing song in Spotify
Objective-C
5
star
15

SensorBox

Arduino sensor box
Arduino
4
star
16

glot-run2

Rust
4
star
17

smartimages

SmartOS IMGAPI Server
Go
4
star
18

gandi-rrr

gandi - Restful Resource Records
Go
2
star
19

notification

CLI tool for creating OS X Notification Center messages
Objective-C
2
star
20

magmod

A magento module generator
Haskell
2
star
21

Performance-Debugging

C
2
star
22

daemons

Start configured applications inside a tmux session
Go
2
star
23

reminders

https://reminders.rasmussen.io/
Elm
2
star
24

pwgen

Web site that generates pronounceable passwords.
JavaScript
2
star
25

Telegraph

C#
1
star
26

imgserver

Smartos dataset server
JavaScript
1
star
27

glot-api-lib

glot api libraries
Go
1
star
28

pushover-irssi

pushover.net irssi script with idle detection
Perl
1
star
29

itunes-track

CLI tool that prints the currently playing song in iTunes
Objective-C
1
star
30

wolfram

IRC bot
JavaScript
1
star
31

iTwatch

#twatch app for iPhone
1
star