Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pomettini committed May 30, 2019
1 parent a5a885e commit 57a1687
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ Cargo.lock
**/*.rs.bk

.vscode/*
.DS_Store
.DS_Store
.idea/*
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ authors = ["Giorgio Pomettini <giorgio.pomettini@gmail.com>"]
[dependencies]
regex = ">=1"
clap = ">=2"
assert_cmd = ">=0.11.1"
assert_cmd = ">=0.11.1"
escargot = ">=0.5"
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,55 @@
[![Build status](https://ci.appveyor.com/api/projects/status/19lf9hwujgk7mlc0?svg=true)](https://ci.appveyor.com/project/Pomettini/stevia)
[![Coverage Status](https://coveralls.io/repos/github/Pomettini/stevia/badge.svg?branch=master)](https://coveralls.io/github/Pomettini/stevia?branch=master)

A lightweight scripting language for simple visual novels that is easy to parse
A lightweight file format for simple visual novels that is easy to parse

It takes a subset of [Ink](https://github.com/inkle/ink) scripting language as the input

## Usage

Build the binary with:

```bash
cargo build --bin stevia
```

Run with:

```bash
./stevia file.ink
```

## Examples

Stevia will transform this:

```text
Hello there
I'm a VN written in the Ink format
Do you like it?
+ [Yes, I like it!] -> like
+ [No, I do not like it] -> hate
=== like
Thank you!
-> END
=== hate
Oh, I see
-> END
```

Into this:

```
P;Hello there|P;I'm a VN written in the Ink format|P;Do you like it?|Q;Yes, I like it!;00120;No, I do not like it;00136|P;Thank you!|E;|P;Oh, I see|E;
```

Still work in progress!
39 changes: 26 additions & 13 deletions src/bin/stevia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,52 @@ fn main() {

mod tests {
use assert_cmd::prelude::*;
use std::fs;
use std::fs::*;
use std::process::Command;

#[test]
fn test_load_no_argument() {
let mut cmd = Command::cargo_bin("stevia").unwrap();
cmd.assert().failure();
Command::cargo_bin("stevia").unwrap().assert().failure();

clean();
}

#[test]
fn test_load_file() {
let mut cmd = Command::cargo_bin("stevia").unwrap();
cmd.arg("examples/example.ink");
cmd.assert().success();
Command::cargo_bin("stevia")
.unwrap()
.arg("examples/example.ink")
.assert()
.success();

clean();
}

#[test]
fn test_load_non_existent_file() {
let mut cmd = Command::cargo_bin("stevia").unwrap();
cmd.arg("examples/nonexistent.ink");
cmd.assert().failure();
Command::cargo_bin("stevia")
.unwrap()
.arg("examples/nonexistent.ink")
.assert()
.failure();

clean();
}

#[test]
fn test_functional_process_file_green() {
let mut cmd = Command::cargo_bin("stevia").unwrap();
cmd.arg("examples/example.ink").assert().success();
Command::cargo_bin("stevia")
.unwrap()
.arg("examples/example.ink")
.assert()
.success();

// Check contents of output file
let expected = "P;Hello there|P;I'm a VN written in the Ink format|P;Do you like it?|Q;Yes, I like it!;00120;No, I do not like it;00136|P;Thank you!|E;|P;Oh, I see|E;";
let contents = fs::read_to_string("example.stevia").expect("Cannot find .stevia file");
let contents = read_to_string("example.stevia").expect("Cannot find .stevia file");

assert_eq!(expected, contents);

clean();
}

Expand All @@ -87,5 +99,6 @@ mod tests {
.arg("*.stevia")
.arg("-delete")
.output()
.unwrap(); }
.unwrap();
}
}

0 comments on commit 57a1687

Please sign in to comment.