# open-judge

> Open Judge Toolkit.

Latest version **1.0.0-alpha.1** (published 2022-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install open-judge
pnpm add open-judge
yarn add open-judge
bun add open-judge
```

Provides the commands `oj`, `open-judge`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-alpha.1 |
| Published | 2022-10-03 |
| First published | 2022-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 28.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | JacobLinCool |
| Maintainers | jacoblincool |

## Links

- npm: https://www.npmjs.com/package/open-judge
- npm.io page: https://npm.io/package/open-judge

## Dependencies (4)

- [ora](https://npm.io/package/ora.md) ^5.4.1
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [commander](https://npm.io/package/commander.md) ^9.4.0
- [dockerode](https://npm.io/package/dockerode.md) ^3.3.4

## Recent versions

- 1.0.0-alpha.1 (latest) — 2022-10-03
- 0.1.0-pre.3 — 2022-05-13
- 0.1.0-pre.2 — 2022-05-11
- 0.1.0-pre.1 — 2022-05-10

## README

# Open Judge Kit

Open Judge Toolkit.

## Execute

The easiest way to try the toolkit is `open-judge execute` (`oj exe`).

It create a isolated environment of the current directory and execute the command.

```sh
Usage: open-judge execute|exe [options] <command>

run command in isolated environment

Arguments:
  command                       command to run

Options:
  -p, --pre <pre-command>       command to run before main command (default: "")
  -e, --env <env...>            environment variables (default: [])
  -b, --base <image>            base image (default: "jacoblincool/workspace-lite")
  -D, --dir <dir>               working directory (default: "current directory")
  -k, --keep                    keep volume after execution (default: false)
  -m, --memory <memory>         memory limit (default: "1g")
  -d, --disk <disk>             disk limit (default: "1g")
  -c, --cpu <cpu>               cpu limit (default: "9")
  -a, --artifact <artifact...>  artifacts to keep (added, changed) (default: [])
  -h, --help                    display help for command
```

```sh
# List all files in the current directory
oj exe ls
```

```sh
# Run `make`, then execute the compiled binary
oj exe --pre "make" "./program"
```

```sh
# Use GCC to compile and execute the program with input, then catch the output into a file artifact
oj exe --artifact added --pre "gcc -o main main.c" "echo '4 4 4 10' | ./main > out.log"
```

```js
{
  stdout: 'stdout\n',
  stderr: 'stderr\n',
  measurement: {
    start: { cpu: 16230000, mem: 327680 },
    prepare: { cpu: 114738000, mem: 491520 },
    run: { cpu: 128680000, mem: 499712 }
  },
  code: 0,
  changes: [ { path: 'out.log', kind: 1 } ],
  artifact: 'oj-53odawst3qh'
}
```

The artifact (`out.log`) has been created in an isolated docker volume.

* The `prepare` stage is the time of the pre-command execution.
* The `run` stage is the time of the command execution.

---
_Source: https://npm.io/package/open-judge · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
