Repository navigation
Expand file tree
/
Copy pathoutput.rs
More file actions
67 lines (56 loc) · 1.94 KB
/
Copy pathoutput.rs
File metadata and controls
67 lines (56 loc) · 1.94 KB
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
//! Output and input format definitions for exec mode.
use clap::ValueEnum;
use serde::{Deserialize, Serialize};
/// Output format for exec mode.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ExecOutputFormat {
/// Human-readable text output (default).
#[default]
Text,
/// Structured JSON output with final result.
Json,
/// Streaming JSON Lines showing execution in real-time.
/// Each line is a separate JSON event.
StreamJson,
/// Deprecated alias for stream-json.
Debug,
/// JSON-RPC streaming protocol for multi-turn conversations.
/// Reads JSONL from stdin, outputs JSON-RPC responses.
StreamJsonrpc,
}
impl std::fmt::Display for ExecOutputFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ExecOutputFormat::Text => write!(f, "text"),
ExecOutputFormat::Json => write!(f, "json"),
ExecOutputFormat::StreamJson => write!(f, "stream-json"),
ExecOutputFormat::Debug => write!(f, "debug"),
ExecOutputFormat::StreamJsonrpc => write!(f, "stream-jsonrpc"),
}
}
}
/// Input format for exec mode.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ExecInputFormat {
/// Standard text input (default).
#[default]
Text,
/// JSON-RPC streaming for multi-turn sessions.
StreamJsonrpc,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_output_format_display() {
assert_eq!(ExecOutputFormat::Text.to_string(), "text");
assert_eq!(ExecOutputFormat::Json.to_string(), "json");
assert_eq!(ExecOutputFormat::StreamJson.to_string(), "stream-json");
assert_eq!(
ExecOutputFormat::StreamJsonrpc.to_string(),
"stream-jsonrpc"
);
}
}