pub enum DiffOptions {
Typed {
format: DiffFormat,
whitespace: WhitespaceHandling,
},
Raw(String),
}Expand description
Diff routine options passed via -doptions, shared by commands such as
p4 diff, p4 diff2, p4 describe, and p4 annotate.
The structured (Typed) options split into two
orthogonal dimensions — DiffFormat (output format) and
WhitespaceHandling — each of which is internally mutually exclusive.
All options are assembled with a DiffOptionsBuilder, whose mode type
parameter tracks at compile time whether structured or raw options are
being built; both builder states convert into this type via From, and
command methods accept impl Into<DiffOptions> so a builder can be
passed directly.
§Examples
use perforce_cli::cmd::{DiffOptions, DiffOptionsBuilder};
// `-dub`: unified format, ignore changes within whitespace
let opts = DiffOptions::from(
DiffOptionsBuilder::unified(None).ignore_changes_within_whitespace(),
);
// `-dc3`: context format with 3 lines of context
let opts = DiffOptions::from(DiffOptionsBuilder::context(Some(3)));
// `-d-C 25`: pass `-C 25` straight to an external diff program
let opts = DiffOptions::from(DiffOptionsBuilder::raw("-C 25"));Variants§
Typed
Structured diff options (the documented subset of the standard UNIX diff flags).
Raw(String)
Raw option string passed directly to the underlying diff routine
(useful with an external diff program configured via P4DIFF).
Implementations§
Source§impl DiffOptions
impl DiffOptions
Sourcepub fn format(&self) -> Option<DiffFormat>
pub fn format(&self) -> Option<DiffFormat>
Returns the selected output format, or None if this is a
Raw value.
Sourcepub fn whitespace_handling(&self) -> Option<WhitespaceHandling>
pub fn whitespace_handling(&self) -> Option<WhitespaceHandling>
Returns the selected whitespace handling, or None if this is a
Raw value.
Sourcepub fn raw_str(&self) -> Option<&str>
pub fn raw_str(&self) -> Option<&str>
Returns the raw option string, or None if this is a
Typed value.
Sourcepub fn inject_arg(&self, command: &mut Command)
pub fn inject_arg(&self, command: &mut Command)
Injects the -doptions argument into command.
If this is a Typed value with both the format
and whitespace handling at their defaults, no -d argument is emitted.