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