Skip to content

Commit 6ea1af7

Browse files
committed
Output rendered Typst code to console for debugging
1 parent 4d92454 commit 6ea1af7

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/main.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use tracing_subscriber::{self, EnvFilter};
99

1010
use technique::formatting::*;
1111
use technique::formatting::{self};
12+
1213
use technique::parsing;
1314

1415
mod problem;
@@ -108,6 +109,15 @@ fn main() {
108109
PDF. By default this will highlight the source of the \
109110
input file for the purposes of reviewing the raw \
110111
procedure.")
112+
.arg(
113+
Arg::new("output")
114+
.short('o')
115+
.long("output")
116+
.value_parser(["pdf", "typst"])
117+
.default_value("pdf")
118+
.action(ArgAction::Set)
119+
.help("Output format: pdf (default) or typst markup.")
120+
)
111121
.arg(
112122
Arg::new("filename")
113123
.required(true)
@@ -215,6 +225,12 @@ fn main() {
215225
print!("{}", result);
216226
}
217227
Some(("render", submatches)) => {
228+
let output_format = submatches
229+
.get_one::<String>("output")
230+
.unwrap();
231+
232+
debug!(output_format);
233+
218234
let filename = submatches
219235
.get_one::<String>("filename")
220236
.unwrap(); // argument are required by definition so always present
@@ -244,7 +260,17 @@ fn main() {
244260
};
245261

246262
let result = formatting::render(&Typst, &technique, 70);
247-
rendering::via_typst(&filename, &result);
263+
264+
match output_format.as_str() {
265+
"typst" => {
266+
print!("{}", result);
267+
// and exit
268+
std::process::exit(0);
269+
}
270+
_ => {
271+
rendering::via_typst(&filename, &result);
272+
}
273+
}
248274
}
249275
Some(_) => {
250276
println!("No valid subcommand was used")

0 commit comments

Comments
 (0)