specfold_core/check/
context.rs1use super::scope::Scope;
4use crate::corpus::Corpus;
5use crate::graph::Graph;
6use crate::workspace::vcs;
7
8#[derive(Debug, Clone, Default)]
9pub struct Options {
10 pub run_commands: bool,
12 pub external: bool,
14 pub online: bool,
16 pub guards: bool,
18}
19
20pub struct Ctx<'a> {
21 pub corpus: &'a Corpus,
22 pub graph: &'a Graph,
23 pub scope: &'a Scope,
24 pub opts: &'a Options,
25}
26
27impl Ctx<'_> {
28 pub fn previous(&self, path: &str) -> Option<String> {
30 let base = self.scope.base.as_deref()?;
31 vcs::show(&self.corpus.cfg.root, base, path)
32 }
33
34 pub fn current(&self, path: &str) -> Option<String> {
36 match self.scope.range {
37 super::scope::Range::Staged => vcs::show_staged(&self.corpus.cfg.root, path),
38 _ => std::fs::read_to_string(self.corpus.cfg.root.join(path)).ok(),
39 }
40 }
41}