Fix DirectIO cli toggle behaviour.
This commit is contained in:
+9
-4
@@ -31,18 +31,23 @@ pub struct Args {
|
||||
#[arg(short, long, default_value_t = crate::FB_SECTOR_SIZE)]
|
||||
pub sector_size: usize,
|
||||
|
||||
// !!! ArgAction behaviour is backwards !!!
|
||||
// ArgAction::SetFalse by default evaluates to true,
|
||||
// ArgAction::SetTrue by default evaluates to false.
|
||||
// !!! ArgAction behaviour is backwards to what you want to think !!!
|
||||
// ArgAction::SetFalse sets default value to true,
|
||||
// ArgAction::SetTrue sets default value to false.
|
||||
//
|
||||
// This is because ArgAction refers to the action that should happen *when* the flag is
|
||||
// provided.
|
||||
// I.e. a flag to disable something should take action to set the value as false.
|
||||
//
|
||||
/// Upon encountering a read error, reopen the source file before continuing.
|
||||
#[arg(short, long, action = ArgAction::SetTrue)]
|
||||
pub reopen_on_error: bool,
|
||||
|
||||
/// Use O_DIRECT to bypass kernel buffer when reading.
|
||||
/// It is very unlikely that you will want to disable this.
|
||||
//
|
||||
// BSD seems to support O_DIRECT, but MacOS for certain does not.
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
#[arg(short, long = "direct", action = ArgAction::SetFalse)]
|
||||
#[arg(short = 'd', long = "no-direct", action = ArgAction::SetFalse)]
|
||||
pub direct_io: bool,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user