Skip to content

Commit 5c70c21

Browse files
authored
Interactive runner that walks a Technique (#103)
Introduces an interactive runner that walks a Technique, prompts the user with the details of the next step, takes their input, then records the result. This branch adds _technique run_ and _technique resume_ to the command-line interface. The _run_ subcommand reads a Technique document as parameter and starts presenting its steps. the _resume_ subcommand resumes an interrupted run, taking a "run id" parameter to do so. This functionality is carried out in a new top-level `runner::` module, with an `evaluate()` effectively taking an Operation and an Environment and evaluating it to a Value. The Value type is now defined in a new top-level `value::` module, following the naming convention originally established in Technique v0. This lands an initial local state store for holding PFFTT files, written in _.store/_ in the present directory. These are named for the Technique document being executed and include basic information recording when each step is completed. Branch also addresses a few corner cases that emerged while improving test coverage.
2 parents 2de072a + 92ac888 commit 5c70c21

33 files changed

Lines changed: 3387 additions & 32 deletions

File tree

.github/workflows/check.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Check
22
on:
33
pull_request:
44
workflow_dispatch:
5+
permissions:
6+
contents: read
57

68
jobs:
79
build:

.github/workflows/release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Release
22
on:
33
release:
44
types: [published]
5+
permissions:
6+
contents: read
57

68
jobs:
79
build:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# rendering artifacts
66
*.pdf
77
.*.typ
8+
/.store
89

910
# documentation symlinks
1011
/doc/references

Cargo.lock

Lines changed: 53 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ owo-colors = "4"
1616
regex = "1.11.1"
1717
serde = { version = "1.0.209", features = [ "derive" ] }
1818
serde_json = "1.0"
19+
time = { version = "0.3", features = [ "formatting" ] }
1920
tinytemplate = "1.2.1"
2021

2122
tracing = "0.1.40"

src/domain/engine.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ impl<'i> Scope<'i> {
7979
/// Filters out ResponseBlock, CodeBlock, AttributeBlock, etc.
8080
pub fn substeps(&self) -> impl Iterator<Item = &Scope<'i>> {
8181
self.children()
82-
.filter(|s| {
83-
matches!(
84-
s,
85-
Scope::DependentBlock { .. } | Scope::ParallelBlock { .. }
86-
)
87-
})
82+
.filter(|s| s.is_step())
8883
}
8984

9085
/// Returns the text content of this step (first paragraph).
@@ -168,10 +163,10 @@ impl<'i> Scope<'i> {
168163

169164
/// Returns true if this scope represents a step (dependent or parallel).
170165
pub fn is_step(&self) -> bool {
171-
matches!(
172-
self,
173-
Scope::DependentBlock { .. } | Scope::ParallelBlock { .. }
174-
)
166+
match self {
167+
Scope::DependentBlock { .. } | Scope::ParallelBlock { .. } => true,
168+
_ => false,
169+
}
175170
}
176171

177172
/// Returns section info (numeral, title) if this is a SectionChunk.

src/domain/nasa_esa_iss/adapter.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,19 @@ fn inline_procedures(doc: &mut Document) {
5151
}
5252
}
5353

54-
doc.body.retain(|node| {
55-
!matches!(node, Node::Sequential { title: None, invocations, .. } if !invocations.is_empty())
56-
});
54+
doc.body
55+
.retain(|node| {
56+
if let Node::Sequential {
57+
title: None,
58+
invocations,
59+
..
60+
} = node
61+
{
62+
invocations.is_empty()
63+
} else {
64+
true
65+
}
66+
});
5767
}
5868

5969
/// Collect ordinals from invocation-only steps: procedure_name -> ordinal.

src/formatting/formatter.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,13 @@ impl<'i> Formatter<'i> {
685685
if func
686686
.parameters
687687
.iter()
688-
.any(|p| matches!(p, Expression::Multiline(_, _, _))) =>
688+
.any(|p| {
689+
if let Expression::Multiline(_, _, _) = p {
690+
true
691+
} else {
692+
false
693+
}
694+
}) =>
689695
{
690696
line.flush();
691697
self.add_fragment_reference(Syntax::Neutral, " ");

src/highlighting/typst.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ mod check {
7474
let result = escape_typst(input);
7575

7676
// Should return borrowed reference when no quotes to escape
77-
assert!(matches!(result, Cow::Borrowed(_)));
77+
if let Cow::Borrowed(_) = result {
78+
// ok
79+
} else {
80+
panic!("expected Cow::Borrowed");
81+
}
7882
assert_eq!(result, "hello world");
7983
}
8084

@@ -84,7 +88,11 @@ mod check {
8488
let result = escape_typst(input);
8589

8690
// Should return owned string when quotes need escaping
87-
assert!(matches!(result, Cow::Owned(_)));
91+
if let Cow::Owned(_) = result {
92+
// ok
93+
} else {
94+
panic!("expected Cow::Owned");
95+
}
8896
assert_eq!(result, "hello \\\"world\\\"");
8997
}
9098

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ pub mod language;
55
pub mod parsing;
66
pub mod program;
77
pub(crate) mod regex;
8+
pub mod runner;
89
pub mod templating;
910
pub mod translation;
11+
pub mod value;

0 commit comments

Comments
 (0)