Skip to main content

codex_execpolicy/
decision.rs

1use serde::Deserialize;
2use serde::Serialize;
3
4use crate::error::Error;
5use crate::error::Result;
6
7#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub enum Decision {
10    /// Command may run without further approval.
11    Allow,
12    /// Request explicit user approval; rejected outright when running with `approval_policy="never"`.
13    Prompt,
14    /// Command is blocked without further consideration.
15    Forbidden,
16}
17
18impl Decision {
19    pub fn parse(raw: &str) -> Result<Self> {
20        match raw {
21            "allow" => Ok(Self::Allow),
22            "prompt" => Ok(Self::Prompt),
23            "forbidden" => Ok(Self::Forbidden),
24            other => Err(Error::InvalidDecision(other.to_string())),
25        }
26    }
27}