diff --git a/.gitignore b/.gitignore index 2096f01..6f048ac 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ Cargo.lock **/*.rs.bk .vscode/* -.DS_Store \ No newline at end of file +.DS_Store +.idea/* \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index a63c6ee..27babb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +6,5 @@ authors = ["Giorgio Pomettini "] [dependencies] regex = ">=1" clap = ">=2" -assert_cmd = ">=0.11.1" \ No newline at end of file +assert_cmd = ">=0.11.1" +escargot = ">=0.5" \ No newline at end of file diff --git a/README.md b/README.md index 29c39aa..7b91d3e 100644 --- a/README.md +++ b/README.md @@ -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! \ No newline at end of file diff --git a/src/bin/stevia.rs b/src/bin/stevia.rs index b1cbf78..687403d 100644 --- a/src/bin/stevia.rs +++ b/src/bin/stevia.rs @@ -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(); } @@ -87,5 +99,6 @@ mod tests { .arg("*.stevia") .arg("-delete") .output() - .unwrap(); } + .unwrap(); + } }