1crate::ix!();
2
3#[derive(Getters,StructOpt, Debug)]
5#[structopt(name = "act")]
6pub struct CrateActivityCli {
7
8 #[structopt(long, short = "i", help = "Ignores crate activity cache, scrapes activity data again")]
9 #[getset(get = "pub")]
10 ignore_cache: bool,
11
12 #[structopt(long, help = "Enable all analyses at once")]
14 #[getset(get = "pub")]
15 all: bool,
16
17 #[structopt(long, short = "c", help = "Display correlation analysis")]
19 #[getset(get = "pub")]
20 show_correlations: bool,
21
22 #[structopt(long, short = "p", help = "Perform PCA analysis")]
24 #[getset(get = "pub")]
25 perform_pca: bool,
26
27 #[structopt(long, short = "h", help = "Perform hierarchical clustering")]
29 #[getset(get = "pub")]
30 perform_hierarchical_clustering: bool,
31
32 #[structopt(long, short = "n", help = "Perform correlation network analysis")]
34 #[getset(get = "pub")]
35 correlation_network: bool,
36
37 #[structopt(long, default_value = "0.7", help = "Correlation threshold for network edges")]
39 #[getset(get = "pub")]
40 network_threshold: f64,
41
42 #[structopt(long, short = "g", help = "Target number of communities for Girvan–Newman")]
44 #[getset(get = "pub")]
45 girvan_newman: Option<usize>,
46
47 #[structopt(long, short = "b", help = "Compute betweenness centrality and display top nodes")]
49 #[getset(get = "pub")]
50 compute_betweenness: bool,
51
52 #[structopt(long, short = "s", help = "Print a summary of the network graph")]
54 #[getset(get = "pub")]
55 print_summary: bool,
56
57 #[structopt(long, short = "t", help = "Compute time-lagged correlations")]
59 #[getset(get = "pub")]
60 time_lag_correlations: bool,
61
62 #[structopt(long, default_value = "7", help = "Maximum lag (in days) to consider for time-lag correlations")]
64 #[getset(get = "pub")]
65 max_lag: i32,
66
67 #[structopt(long, default_value = "24.0", help = "Z-score threshold for outlier detection")]
69 #[getset(get = "pub")]
70 outlier_z_threshold: f64,
71
72 #[structopt(long, help = "Downweight outliers instead of removing them")]
74 #[getset(get = "pub")]
75 downweight_outliers: bool,
76
77 #[structopt(long, default_value = "0.1", help = "Downweight factor for outliers")]
79 #[getset(get = "pub")]
80 outlier_weight: f64,
81
82 #[structopt(long, help = "Disable outlier detection and handling")]
84 disable_outlier_handling: bool,
85
86 #[structopt(long, help = "If true, we will print each individual crate per group")]
87 #[getset(get="pub")]
88 expand_groups: bool,
89
90 #[structopt(long, default_value = "2", help = "Minimum group size required to treat them as a group")]
91 #[getset(get="pub")]
92 min_group_size: usize,
93
94 #[structopt(long, short = "v", help = "Enable tracing")]
95 #[getset(get="pub")]
96 verbose: bool,
97}
98
99impl CrateActivityCli {
100
101 pub fn read_command_line() -> Self {
102 let mut cli = CrateActivityCli::from_args();
103 cli.apply_all_flag();
104 cli
105 }
106
107 pub fn disable_outlier_handling(&self) -> bool {
108
109 #[cfg(test)]
110 let disable_outliers_override = true; #[cfg(not(test))]
113 let disable_outliers_override = false;
114
115 let disable_outliers = self.disable_outlier_handling || disable_outliers_override;
116
117 disable_outliers
118 }
119
120 pub fn apply_all_flag(&mut self) {
122 if self.all {
123 self.show_correlations = true;
124 self.perform_pca = true;
125 self.perform_hierarchical_clustering = true;
126 self.correlation_network = true;
127 self.compute_betweenness = true;
128 self.print_summary = true;
129 self.time_lag_correlations = true;
130 }
132 }
133}