https://github.com/ryym/slv
Manage your solutions of programming problems with tests
https://github.com/ryym/slv
cli programming-challenges
Last synced: 20 days ago
JSON representation
Manage your solutions of programming problems with tests
- Host: GitHub
- URL: https://github.com/ryym/slv
- Owner: ryym
- Created: 2017-12-17T11:48:35.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-03-27T00:11:14.000Z (about 1 month ago)
- Last Synced: 2025-03-27T01:24:15.467Z (about 1 month ago)
- Topics: cli, programming-challenges
- Language: Go
- Homepage:
- Size: 77.1 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Slv
[](https://circleci.com/gh/ryym/slv)
[](https://ci.appveyor.com/project/ryym/slv)Slv is a command line tool for managing source files of common programming contests, along with test cases.
Slv can manage any programs that take inputs from stdin and output results to stdout regardless of language.
You can:- define test cases as TOML files
- write source code in multiple languagesFor example, Slv can be used to manage solution code for
[AOJ][aoj] and [AtCoder][at-coder] holding online programming contests,
or for [CodeIQ][code-iq] which provides various programming problems,
because they require a program that uses stdin / stdout.[aoj]: http://judge.u-aizu.ac.jp/onlinejudge/index.jsp
[at-coder]: https://atcoder.jp/?lang=en
[code-iq]: https://codeiq.jp/## Installation
- [GitHub Releases](https://github.com/ryym/slv/releases)
- `go get -u github.com/ryym/slv`## Overview
```
NAME:
slv - Helps you solve programming problemsUSAGE:
slv [global options] command [command options] [arguments...]VERSION:
0.2.0COMMANDS:
new, n Create new problem directory
test, t Run tests for the specified source code
compile Compile without running
run, r Run the specified source code
help, h Shows a list of commands or help for one commandGLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
```## Usage
First, create a new problem directory.
```bash
$ slv new hello
$ ls hello
src/ test/
$ cd hello
```Next, write your solution and save it in the `src` directory.
Any file name is fine as long as the extension is correct.```ruby
# src/hello.rbname = gets.chomp
puts "hello, #{name}."
```Then prepare the test cases in the `test` directory.
Any file name is fine again.```toml
# test/test.toml[[test]]
in = "alice"
out = "hello, alice."[[test]]
in = "bob"
out = "hello, bob."
```Now you can test your solution!
```bash
$ slv test src/hello.rb
testing hello.rb...
..[OK] All: 2, Passed: 2, Failed: 0
```You can also specify the solution by the language name or its extension.
```bash
$ slv test ruby
testing hello.rb...
..[OK] All: 2, Passed: 2, Failed: 0
# Or
$ slv test rb
testing hello.rb...
..[OK] All: 2, Passed: 2, Failed: 0
```When your test fails, Slv displays the output diff.
For example, add a new test case which expects a different output:```toml
# test/test2.toml
# (You can store any number of test case files in the `test` directory)[[test]]
in = "anonymous"
out = "what your name?"
```This results in the error like this:
```diff
$ slv test rb
testing hello.rb...
..Ftest2.toml[0]:
-what your name?
+hello, anonymous.[FAILED] All: 3, Passed: 2, Failed: 1
```## How to write test cases
Test cases are loaded from all TOML files in the `test` directory.
See the [sample test cases](sample_cases.toml) as a reference.## Customize
Slv supports some major languages by default as [TOML config][default-langs].
You can use any language with Slv by adding the configuration to `.slv.toml`.
Slv searches `.slv.toml` from current directory and its all parent directories.[default-langs]: https://github.com/ryym/slv/blob/master/slv/config.go
## Development
```sh
git clone https://github.com/ryym/slv
go test ./...
```