Skip to main content

osp_cli/dsl/
mod.rs

1//! Canonical document-first pipeline DSL.
2//!
3//! A pipeline is a command followed by zero or more transformation stages
4//! separated by `|`. The stages transform the rows returned by the command:
5//!
6//! ```text
7//! "orch task list | F status=running | S created | L 10"
8//!  ─────────────────  ─────────────────────────────────
9//!     command              pipeline stages
10//! ```
11//!
12//! Data flow:
13//!
14//! ```text
15//! raw line
16//!   │
17//!   ▼  parse_pipeline(line)
18//!   Pipeline { command: "orch task list",
19//!              stages:  ["F status=running", "S created", "L 10"] }
20//!   │
21//!   │  caller dispatches the command and gets rows back
22//!   │
23//!   ▼  apply_pipeline(rows, &stages)
24//!   OutputResult  ← filtered · sorted · limited rows
25//! ```
26//!
27//! The main public surface:
28//!
29//! - [`crate::dsl::parse_pipeline`] turns a raw line into a [`crate::dsl::Pipeline`] value
30//! - [`crate::dsl::parse_stage`] parses one stage when the command has already been split away
31//! - [`crate::dsl::apply_pipeline`] / [`crate::dsl::apply_output_pipeline`] apply stages to
32//!   existing rows
33//! - [`crate::dsl::registered_verbs`] returns metadata for all supported stage verbs
34//! - [`crate::dsl::verb_info`] looks up a single verb by name
35//!
36//! Choose the smallest entrypoint that matches your starting point:
37//!
38//! - if you only need to split `"command | stages"` into structured pieces, use
39//!   [`crate::dsl::parse_pipeline`]
40//! - if you already have one raw stage like `"F uid=alice"` and need to inspect
41//!   its verb/spec shape, use [`crate::dsl::parse_stage`]
42//! - if your command already produced `Vec<Row>`, use [`crate::dsl::apply_pipeline`]
43//! - if you already have an [`crate::core::output_model::OutputResult`] and want
44//!   to preserve its semantic document or render metadata, use
45//!   [`crate::dsl::apply_output_pipeline`]
46//! - if your rows come from an iterator and you want streamable stages to stay
47//!   streamable for as long as possible, use [`crate::dsl::execute_pipeline_streaming`]
48//!
49//! Common verbs: `F` (filter), `P` (project), `S` (sort), `G` (group),
50//! `A` (aggregate), `L` (limit), `V`/`K` (quick search), `U` (unroll),
51//! `JQ` (jq expression). See [`crate::dsl::registered_verbs`] for the full list
52//! with streaming notes in [`crate::dsl::VerbStreaming`].
53
54pub(crate) mod compiled;
55pub(crate) mod eval;
56pub(crate) mod model;
57pub(crate) mod parse;
58pub(crate) mod verb_info;
59
60mod engine;
61mod value;
62mod verbs;
63
64pub use engine::{
65    apply_output_pipeline, apply_pipeline, execute_pipeline, execute_pipeline_streaming,
66};
67pub use parse::pipeline::{Pipeline, parse_pipeline, parse_stage};
68pub use verb_info::{
69    VerbInfo, VerbStreaming, is_registered_explicit_verb, registered_verbs, render_streaming_badge,
70    verb_info,
71};
72
73#[cfg(test)]
74mod tests;