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
87impl CrateActivityCli {
88
89 pub fn read_command_line() -> Self {
90 let mut cli = CrateActivityCli::from_args();
91 cli.apply_all_flag();
92 cli
93 }
94
95 pub fn disable_outlier_handling(&self) -> bool {
96
97 #[cfg(test)]
98 let disable_outliers_override = true; #[cfg(not(test))]
101 let disable_outliers_override = false;
102
103 let disable_outliers = self.disable_outlier_handling || disable_outliers_override;
104
105 disable_outliers
106 }
107
108 pub fn apply_all_flag(&mut self) {
110 if self.all {
111 self.show_correlations = true;
112 self.perform_pca = true;
113 self.perform_hierarchical_clustering = true;
114 self.correlation_network = true;
115 self.compute_betweenness = true;
116 self.print_summary = true;
117 self.time_lag_correlations = true;
118 }
120 }
121}