tui_dispatch_debug/
cli.rs1use clap::Args;
2use std::path::PathBuf;
3
4use crate::debug::ActionLoggerConfig;
5
6#[derive(Args, Debug, Clone, Default)]
8#[command(next_help_heading = "Debug")]
9pub struct DebugCliArgs {
10 #[arg(long = "debug")]
12 pub enabled: bool,
13
14 #[arg(long = "debug-render-once")]
16 pub render_once: bool,
17
18 #[arg(long = "debug-state-in")]
20 pub state_in: Option<PathBuf>,
21
22 #[arg(long = "debug-actions-in")]
24 pub actions_in: Option<PathBuf>,
25
26 #[arg(long = "debug-actions-out")]
28 pub actions_out: Option<PathBuf>,
29
30 #[arg(long = "debug-actions-include")]
32 pub actions_include: Option<String>,
33
34 #[arg(long = "debug-actions-exclude")]
36 pub actions_exclude: Option<String>,
37
38 #[arg(long = "debug-state-schema-out")]
40 pub state_schema_out: Option<PathBuf>,
41
42 #[arg(long = "debug-actions-schema-out")]
44 pub actions_schema_out: Option<PathBuf>,
45
46 #[arg(long = "debug-replay-timeout", default_value_t = 30)]
48 pub replay_timeout: u64,
49}
50
51impl DebugCliArgs {
52 pub fn action_filter(&self) -> ActionLoggerConfig {
53 match (
54 self.actions_include.as_deref(),
55 self.actions_exclude.as_deref(),
56 ) {
57 (None, None) => ActionLoggerConfig::default(),
58 (Some(include), None) => {
59 ActionLoggerConfig::with_patterns(split_patterns(include), Vec::new())
60 }
61 (include, Some(exclude)) => ActionLoggerConfig::new(include, Some(exclude)),
62 }
63 }
64
65 pub fn auto_fetch(&self) -> bool {
66 self.state_in.is_none() && self.actions_in.is_none()
67 }
68}
69
70fn split_patterns(value: &str) -> Vec<String> {
71 value
72 .split(',')
73 .map(|pattern| pattern.trim())
74 .filter(|pattern| !pattern.is_empty())
75 .map(|pattern| pattern.to_string())
76 .collect()
77}