Skip to main content

vantage_cmd/vista/
spec.rs

1//! YAML-facing types for the command Vista driver.
2//!
3//! A vista's `cmd:` block carries the Rhai script and optional command /
4//! env overrides. The command and shared env usually come from the
5//! pre-built [`Cmd`](crate::Cmd) the factory is bound to, so most vistas
6//! only need `cmd.rhai`.
7
8use indexmap::IndexMap;
9use serde::{Deserialize, Serialize};
10use vantage_vista::{NoExtras, VistaSpec};
11
12#[derive(Debug, Clone, Default, Serialize, Deserialize)]
13#[serde(deny_unknown_fields)]
14pub struct CmdTableExtras {
15    pub cmd: CmdBlock,
16}
17
18#[derive(Debug, Clone, Default, Serialize, Deserialize)]
19#[serde(deny_unknown_fields)]
20pub struct CmdBlock {
21    /// Per-table command override. Defaults to the factory's `Cmd` command.
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub command: Option<String>,
24    /// Per-table env, merged over (and winning against) the datasource env.
25    #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
26    pub env: IndexMap<String, String>,
27    /// The Rhai script: builds the argv, calls `run(args)`, parses output.
28    pub rhai: String,
29}
30
31#[derive(Debug, Clone, Default, Serialize, Deserialize)]
32#[serde(deny_unknown_fields)]
33pub struct CmdColumnExtras {}
34
35pub type CmdVistaSpec = VistaSpec<CmdTableExtras, CmdColumnExtras, NoExtras>;