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
//! Trigger, coprocess and observer-script definitions.
//!
//! Extracted from the top-level [`super::Config`] struct via `#[serde(flatten)]`.
//! All fields serialise at the top level of the YAML config file -- existing
//! config files remain 100% compatible.
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
/// Regex triggers, coprocess definitions and external observer scripts.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AutomationConfig {
/// Regex trigger definitions that match terminal output and fire actions
#[serde(default)]
pub triggers: Vec<crate::automation::TriggerConfig>,
/// Coprocess definitions for piped subprocess management
#[serde(default)]
pub coprocesses: Vec<crate::automation::CoprocessDefConfig>,
/// External observer script definitions
#[serde(default)]
pub scripts: Vec<crate::scripting::ScriptConfig>,
/// Plugin state entries (O2 Phase 3); empty until the user enables one.
#[serde(default)]
pub plugins: Vec<PluginStateConfig>,
}
/// Per-plugin persisted state (one `plugins:` list entry).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PluginStateConfig {
/// Manifest id; must match a discovered plugin.
pub id: String,
/// Whether the host may run this plugin. Defaults to false: plugins are
/// land-disabled, so a dropped-in plugin directory does nothing until
/// the Settings layer flips this bit.
#[serde(default = "default_plugin_disabled")]
pub enabled: bool,
/// Persisted settings values; validated against the manifest schema at
/// apply time, not parse time.
#[serde(default)]
pub settings: HashMap<String, serde_json::Value>,
/// Status-bar section placement override; the manifest default is used
/// when absent.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub section: Option<crate::status_bar::StatusBarSection>,
}
/// `PluginStateConfig::enabled` serde seed: plugins land disabled.
fn default_plugin_disabled() -> bool {
false
}
impl Default for PluginStateConfig {
fn default() -> Self {
Self {
id: String::new(),
enabled: default_plugin_disabled(),
settings: HashMap::new(),
section: None,
}
}
}