feat: detect and warn if running as root
This commit is contained in:
@@ -295,6 +295,8 @@ pub struct Vim {
|
||||
#[derive(Deserialize, Default, Debug, Merge)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Misc {
|
||||
allow_root: Option<bool>,
|
||||
|
||||
pre_sudo: Option<bool>,
|
||||
|
||||
sudo_command: Option<SudoKind>,
|
||||
@@ -767,6 +769,10 @@ pub struct CommandLineArgs {
|
||||
#[arg(long = "show-skipped")]
|
||||
show_skipped: bool,
|
||||
|
||||
/// Suppress warning and confirmation prompt if running as root
|
||||
#[arg(long = "allow-root")]
|
||||
allow_root: bool,
|
||||
|
||||
/// Tracing filter directives.
|
||||
///
|
||||
/// See: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives
|
||||
@@ -1535,6 +1541,16 @@ impl Config {
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
pub fn allow_root(&self) -> bool {
|
||||
self.opt.allow_root
|
||||
|| self
|
||||
.config_file
|
||||
.misc
|
||||
.as_ref()
|
||||
.and_then(|misc| misc.allow_root)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn sudo_command(&self) -> Option<SudoKind> {
|
||||
self.config_file.misc.as_ref().and_then(|misc| misc.sudo_command)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user