Skip to content

Commit e9b6e92

Browse files
committed
release(cli): v0.15.0
1 parent a58f2c4 commit e9b6e92

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

cli/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cambridge-asm-cli"
3-
version = "0.14.0"
3+
version = "0.15.0"
44
authors = ["SaadiSave <https://github.com/SaadiSave>"]
55
edition = "2021"
66
license = "MPL-2.0"
@@ -21,9 +21,10 @@ serde_json = "1"
2121
ron = "0.7"
2222
serde_yaml = "0.8"
2323
bincode = "2.0.0-rc.1"
24+
anyhow = "1"
2425

2526
[dependencies.cambridge-asm]
26-
version = "0.15"
27+
version = "0.18"
2728
default-features = false
2829
features = ["compile"]
2930

cli/src/main.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::ffi::OsString;
1515

1616
#[derive(Parser)]
1717
#[clap(name = "Cambridge Pseudoassembly Interpreter")]
18-
#[clap(version = env!("CARGO_PKG_VERSION"))]
18+
#[clap(version = concat!(env!("CARGO_PKG_VERSION"), "\n", "Library version 0.18.0"))]
1919
#[clap(author = "Saadi Save <github.com/SaadiSave>")]
2020
#[clap(about = "Run pseudoassembly from Cambridge International syllabus 9618 (2021)")]
2121
enum Commands {
@@ -60,6 +60,10 @@ enum Commands {
6060
/// Minify output
6161
#[clap(short = 'm', long = "minify")]
6262
minify: bool,
63+
64+
/// Include debuginfo
65+
#[clap(short, long)]
66+
debug: bool,
6367
},
6468
}
6569

@@ -80,7 +84,7 @@ enum OutFormats {
8084
Bin,
8185
}
8286

83-
fn main() -> std::io::Result<()> {
87+
fn main() -> anyhow::Result<()> {
8488
#[cfg(not(debug_assertions))]
8589
std::panic::set_hook(Box::new(handle_panic));
8690

@@ -101,7 +105,8 @@ fn main() -> std::io::Result<()> {
101105
verbosity,
102106
format,
103107
minify,
104-
} => compile(input, output, verbosity, format, minify)?,
108+
debug,
109+
} => compile(input, output, verbosity, format, minify, debug)?,
105110
}
106111

107112
Ok(())
@@ -114,7 +119,7 @@ fn run(
114119
bench: bool,
115120
format: InFormats,
116121
io: Io,
117-
) -> std::io::Result<()> {
122+
) -> anyhow::Result<()> {
118123
use InFormats::*;
119124

120125
init_logger(verbosity);
@@ -124,19 +129,15 @@ fn run(
124129
let mut timer = bench.then(std::time::Instant::now);
125130

126131
let mut executor = match format {
127-
Pasm => parse::jit::<DefaultSet, _>(String::from_utf8_lossy(&prog_bytes), io),
128-
Json => serde_json::from_str::<CompiledProg>(&String::from_utf8_lossy(&prog_bytes))
129-
.unwrap()
132+
Pasm => parse::jit::<DefaultSet>(String::from_utf8_lossy(&prog_bytes), io).unwrap(),
133+
Json => serde_json::from_str::<CompiledProg>(&String::from_utf8_lossy(&prog_bytes))?
130134
.to_executor::<DefaultSet>(io),
131-
Ron => ron::from_str::<CompiledProg>(&String::from_utf8_lossy(&prog_bytes))
132-
.unwrap()
135+
Ron => ron::from_str::<CompiledProg>(&String::from_utf8_lossy(&prog_bytes))?
133136
.to_executor::<DefaultSet>(io),
134-
Yaml => serde_yaml::from_str::<CompiledProg>(&String::from_utf8_lossy(&prog_bytes))
135-
.unwrap()
137+
Yaml => serde_yaml::from_str::<CompiledProg>(&String::from_utf8_lossy(&prog_bytes))?
136138
.to_executor::<DefaultSet>(io),
137139
Bin => {
138-
bincode::decode_from_slice::<CompiledProg, _>(&prog_bytes, bincode::config::standard())
139-
.unwrap()
140+
bincode::decode_from_slice::<CompiledProg, _>(&prog_bytes, bincode::config::standard())?
140141
.0
141142
.to_executor::<DefaultSet>(io)
142143
}
@@ -146,13 +147,16 @@ fn run(
146147
println!("Total parse time: {:?}", t.elapsed());
147148
std::time::Instant::now()
148149
});
150+
149151
if timer.is_some() || verbosity > 0 {
150152
println!("Execution starts on next line");
151153
}
152154

153155
executor.exec::<DefaultSet>();
154156

155-
let _ = timer.map(|t| println!("Execution done\nExecution time: {:?}", t.elapsed()));
157+
if let Some(t) = timer {
158+
println!("Execution done\nExecution time: {:?}", t.elapsed());
159+
}
156160

157161
Ok(())
158162
}
@@ -164,14 +168,15 @@ fn compile(
164168
verbosity: usize,
165169
format: OutFormats,
166170
minify: bool,
171+
debug: bool,
167172
) -> std::io::Result<()> {
168173
use OutFormats::*;
169174

170175
init_logger(verbosity);
171176

172177
let prog = std::fs::read_to_string(&input)?;
173178

174-
let compiled = compile::compile::<DefaultSet, _>(prog);
179+
let compiled = compile::compile::<DefaultSet>(prog, debug).unwrap();
175180

176181
let output_path = output.unwrap_or_else(|| {
177182
input.push(match format {

0 commit comments

Comments
 (0)