1mod cmd;
3mod dashboard;
4mod events;
5mod metrics;
6mod state;
7
8use clap::Parser;
9pub use cmd::cmd;
10pub use cmd::top;
11pub use dashboard::is_tty;
12use glob::Pattern;
13use url::Url;
14
15use crate::config::api::default_graphql_url;
16
17#[derive(Parser, Debug, Clone)]
19#[command(rename_all = "kebab-case")]
20pub struct Opts {
21 #[arg(default_value = "1000", short = 'i', long)]
23 interval: u32,
24
25 #[arg(short, long)]
27 url: Option<Url>,
28
29 #[arg(short = 'H', long, default_value_t = true)]
31 human_metrics: bool,
32
33 #[arg(short, long)]
37 no_reconnect: bool,
38
39 #[arg(default_value = "*", value_delimiter(','), short = 'c', long)]
41 components: Vec<Pattern>,
42}
43
44impl Opts {
45 pub fn url(&self) -> Url {
48 self.url.clone().unwrap_or_else(default_graphql_url)
49 }
50
51 pub fn web_socket_url(&self) -> Url {
53 let mut url = self.url();
54 url.set_scheme(match url.scheme() {
55 "https" => "wss",
56 _ => "ws",
57 })
58 .expect("Couldn't build WebSocket URL. Please report.");
59
60 url
61 }
62}