Skip to content

Commit aab6be7

Browse files
committed
Move the CLI interface to its own crate
1 parent 4a5f5a8 commit aab6be7

7 files changed

Lines changed: 28 additions & 10 deletions

File tree

B

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Products are not given, please use `=>` or `->` to seperate the two sides

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["stoik", "stoik-gui"]
2+
members = ["stoik", "stoik-gui", "stoik-cli"]
33

44
[profile.release]
55
opt-level = 2 # fast and small wasm

stoik-cli/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "stoik-cli"
3+
version = "0.0.0"
4+
edition = "2021"
5+
default-run = "stoik-cli"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
stoik = { path = "../stoik" }
11+
12+
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
mod err;
2-
mod formula;
3-
41
use std::{
52
collections::{hash_map::Entry, HashMap},
63
env,
74
time::Instant,
85
};
96

10-
use err::StoikError;
11-
use formula::{Molecule, TokenStream};
7+
use stoik::{
8+
formula::{self, Molecule, TokenStream},
9+
StoikError,
10+
};
1211

1312
const HELP_MSG: &str = include_str!("help_msg.txt");
1413

@@ -103,8 +102,8 @@ fn main() {
103102
.collect::<Vec<_>>();
104103
for (element, bal) in balanced {
105104
if !bal || all_moles {
106-
table[1].push(lhs[&element].to_string());
107-
table[2].push(rhs[&element].to_string());
105+
table[1].push(lhs.get(&element).unwrap_or(&0).to_string());
106+
table[2].push(rhs.get(&element).unwrap_or(&0).to_string());
108107
table[0].push(element);
109108
table[3].push(bal.to_string());
110109
}
@@ -222,7 +221,7 @@ fn pad_string(input: &String, length: usize) -> String {
222221
fn construct_mole(
223222
formula: &str,
224223
time_mode: bool,
225-
time_table: &mut Vec<Vec<String>>,
224+
time_table: &mut [Vec<String>],
226225
) -> Result<Molecule, StoikError> {
227226
if time_mode {
228227
time_table[0].push(formula.to_string());

stoik/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
name = "stoik"
33
version = "0.0.0"
44
edition = "2021"
5-
default-run = "stoik"
65

76
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
87

0 commit comments

Comments
 (0)