lernie 0.1.7

lernie: the operator seat — the window and wire client for a yog server
Documentation
//! Every decision one invocation can make, read back as a value.
//!
//! Split at the design-time budget along the seams the module itself has:
//! [`verdicts`] is what a run *says* about this binary and how a [`Verdict`]
//! carries it, [`decisions`] is what `run` *decides* to do, and [`refusals`] is
//! every way a word can fail to be one it answers. The four helpers they share
//! stay here.

use super::{Decided, Verdict, run};
use serde_json::Value;

mod decisions;
mod refusals;
mod verdicts;

/// Build the argument vector the way `main` does, from string literals.
fn argv(words: &[&str]) -> Vec<String> {
    words.iter().map(|w| (*w).to_string()).collect()
}

/// What a run said, for the arguments that decide to say something.
fn said(words: &[&str]) -> Verdict {
    match run(argv(words)) {
        Decided::Say(verdict) => verdict,
        other => panic!("{words:?} decided {other:?}"),
    }
}

/// The envelope a run decided to send, for the arguments that decide to ask.
fn asked(words: &[&str]) -> Value {
    match run(argv(words)) {
        Decided::Ask(envelope) => envelope,
        other => panic!("{words:?} decided {other:?}"),
    }
}

/// The envelope a run decided to ask of EVERY channel — the same envelope,
/// asked of all of them rather than one (bl-0d54).
fn fanned(words: &[&str]) -> Value {
    match run(argv(words)) {
        Decided::Fanned(envelope) => envelope,
        other => panic!("{words:?} decided {other:?}"),
    }
}