1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! Everything this tool says, and the one place it says it.
//!
//! # Why this exists
//!
//! A command that streams prose is usable by a person at a terminal and by
//! nothing else. The workbench shows the same operations as buttons, and what
//! it had to show was a wall of text with no way to know what was running,
//! what finished, or whether anything was happening at all.
//!
//! So every command takes `--jsonl`, and under it every byte the command emits
//! — its own writing, and the output of every process it starts — leaves as
//! JSONL: one [`Record`] per line, from a closed set of document types. Nothing
//! about what a command DOES changes; only how it says it.
//!
//! # One envelope, every tool
//!
//! Every wsb tool takes `--jsonl`, and all answer in this
//! envelope: `{"seq":N,"ts":"…Z","type":"…", …}` — one object per line, the
//! record's own fields flattened beside the envelope's. Logs and typed answers
//! share the one stream: a `machine` record and a `stderr` record are both
//! lines, and a consumer selects on `type` rather than on which pipe it read
//! from. That is what makes a reader of one tool a reader of all three.
//!
//! # The discipline that makes "every byte" true
//!
//! Text can only escape this process through:
//!
//! * [`outln!`] / [`out!`] / [`errln!`] / [`err!`] — this module's macros,
//! which write to the terminal in human mode and package the text in
//! JSONL mode; and
//! * [`Command`] — the one process type this crate starts, which gives a child
//! the terminal in human mode and captures the streams the caller left to
//! inherit when output is being packaged.
//!
//! `println!`, `eprintln!` and `std::process::Command` do not appear anywhere
//! else in this crate, and tests assert it (TEST9660, TEST9661). That is what
//! makes the promise a property of the source rather than a habit.
pub use Command;
pub use ;
pub use ;
/// Report why the run is ending badly.
///
/// In human mode this writes the message the way the command always has. When
/// output is being packaged it emits a [`Record::Failure`] — the one record a
/// consumer has to look at to know what went wrong, rather than reading the
/// last few `stderr` lines and guessing which of them was the cause.
/// Say where this run is being written down.
///
/// The first line of a run, before anything it was asked to do. A packaged run
/// gets it as a `Message` with the `log-file` code, so a consumer can pick the
/// path out without matching on wording; a terminal gets one dim line, because
/// what somebody wants from it is to be able to find the file later — not to
/// read it now.
///
/// It goes to STDERR on a terminal: a command whose stdout is being piped into
/// something else must not have a path prepended to its answer.
/// Say something as data as well as on screen.
///
/// In human mode this writes the text the way the command always has. When
/// output is being packaged it emits a [`Record::Message`] instead, so a
/// consumer gets the level and the code rather than having to recognise the
/// wording.