codex_wrapper/command/
features.rs1use crate::Codex;
5use crate::command::CodexCommand;
6use crate::error::Result;
7use crate::exec::{self, CommandOutput};
8
9#[derive(Debug, Clone, Default)]
11pub struct FeaturesListCommand;
12
13impl FeaturesListCommand {
14 #[must_use]
15 pub fn new() -> Self {
16 Self
17 }
18}
19
20impl CodexCommand for FeaturesListCommand {
21 type Output = CommandOutput;
22
23 fn args(&self) -> Vec<String> {
24 vec!["features".into(), "list".into()]
25 }
26
27 async fn execute(&self, codex: &Codex) -> Result<CommandOutput> {
28 exec::run_codex(codex, self.args()).await
29 }
30}
31
32#[derive(Debug, Clone)]
34pub struct FeaturesEnableCommand {
35 feature: String,
36}
37
38impl FeaturesEnableCommand {
39 #[must_use]
40 pub fn new(feature: impl Into<String>) -> Self {
41 Self {
42 feature: feature.into(),
43 }
44 }
45}
46
47impl CodexCommand for FeaturesEnableCommand {
48 type Output = CommandOutput;
49
50 fn args(&self) -> Vec<String> {
51 vec!["features".into(), "enable".into(), self.feature.clone()]
52 }
53
54 async fn execute(&self, codex: &Codex) -> Result<CommandOutput> {
55 exec::run_codex(codex, self.args()).await
56 }
57}
58
59#[derive(Debug, Clone)]
61pub struct FeaturesDisableCommand {
62 feature: String,
63}
64
65impl FeaturesDisableCommand {
66 #[must_use]
67 pub fn new(feature: impl Into<String>) -> Self {
68 Self {
69 feature: feature.into(),
70 }
71 }
72}
73
74impl CodexCommand for FeaturesDisableCommand {
75 type Output = CommandOutput;
76
77 fn args(&self) -> Vec<String> {
78 vec!["features".into(), "disable".into(), self.feature.clone()]
79 }
80
81 async fn execute(&self, codex: &Codex) -> Result<CommandOutput> {
82 exec::run_codex(codex, self.args()).await
83 }
84}
85
86#[cfg(test)]
87mod tests {
88 use super::*;
89
90 #[test]
91 fn features_list_args() {
92 assert_eq!(FeaturesListCommand::new().args(), vec!["features", "list"]);
93 }
94
95 #[test]
96 fn features_enable_args() {
97 assert_eq!(
98 FeaturesEnableCommand::new("web-search").args(),
99 vec!["features", "enable", "web-search"]
100 );
101 }
102
103 #[test]
104 fn features_disable_args() {
105 assert_eq!(
106 FeaturesDisableCommand::new("web-search").args(),
107 vec!["features", "disable", "web-search"]
108 );
109 }
110}