-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathexperimental.rs
More file actions
53 lines (48 loc) · 1.59 KB
/
experimental.rs
File metadata and controls
53 lines (48 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use crate::local_logger::icons::Icon;
use clap::Args;
use console::style;
/// Experimental flags that may change or be removed without notice.
///
/// These flags are under active development and their behavior is not guaranteed
/// to remain stable across releases.
#[derive(Args, Debug, Clone)]
pub struct ExperimentalArgs {
/// Enable valgrind's --fair-sched option.
#[arg(
long,
default_value_t = false,
help_heading = "Experimental",
env = "CODSPEED_EXPERIMENTAL_FAIR_SCHED"
)]
pub experimental_fair_sched: bool,
}
impl ExperimentalArgs {
/// Returns the names of all experimental flags that were explicitly set by the user.
pub fn active_flags(&self) -> Vec<&'static str> {
let mut flags = Vec::new();
if self.experimental_fair_sched {
flags.push("--experimental-fair-sched");
}
flags
}
/// If any experimental flags are active, prints a warning to stderr.
pub fn warn_if_active(&self) {
let flags = self.active_flags();
if flags.is_empty() {
return;
}
let flag_list = flags
.iter()
.map(|f| style(*f).bold().to_string())
.collect::<Vec<_>>()
.join(", ");
eprintln!(
"\n {} Experimental flags enabled: {}\n \
These may change or be removed without notice.\n \
Share feedback at {}.\n",
style(Icon::Warning.to_string()).yellow(),
flag_list,
style("https://github.com/CodSpeedHQ/codspeed/issues").underlined(),
);
}
}