1use clap::{Parser, ValueEnum};
2
3#[derive(Copy, Clone, Debug, ValueEnum)]
5pub enum GraphType {
6 Mermaid,
8 Dot,
10 Json,
12}
13
14impl std::fmt::Display for GraphType {
15 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16 write!(f, "{:?}", self)
17 }
18}
19
20#[derive(Parser, Debug, Default)]
22pub struct GraphConfig {
23 #[clap(long)]
25 pub graph: Option<GraphType>,
26
27 #[clap(long)]
29 pub file: bool,
30
31 #[clap(long)]
33 pub no_metadata: bool,
34
35 #[clap(long)]
37 pub no_location_groups: bool,
38
39 #[clap(long)]
41 pub no_tee_ids: bool,
42
43 #[clap(long)]
45 pub long_labels: bool,
46}
47
48impl GraphConfig {
49 pub fn should_exit_after_graph_generation(&self) -> bool {
52 self.file && self.graph.is_some()
53 }
54}
55
56#[derive(Debug, Clone)]
59pub struct VisualizerConfig {
60 pub base_url: String,
62 pub enable_compression: bool,
64 pub max_url_length: usize,
66 pub min_compression_size: usize,
68}
69
70impl Default for VisualizerConfig {
71 fn default() -> Self {
72 let base_url = std::env::var("HYDRO_VISUALIZER_URL")
74 .unwrap_or_else(|_| "https://hydro.run/docs/hydroscope".to_string());
75
76 Self {
77 base_url,
78 enable_compression: true,
79 max_url_length: 4000,
80 min_compression_size: 1000,
81 }
82 }
83}
84
85impl VisualizerConfig {
86 pub fn with_base_url(base_url: impl Into<String>) -> Self {
88 Self {
89 base_url: base_url.into(),
90 ..Default::default()
91 }
92 }
93
94 pub fn local() -> Self {
96 Self::with_base_url("http://localhost:3000/hydroscope")
97 }
98
99 pub fn without_compression(mut self) -> Self {
101 self.enable_compression = false;
102 self
103 }
104}