wip patch mode

patch_format
Wilfred Hughes 2024-02-02 08:44:06 +07:00
parent 3476a68efb
commit 7d0d0113aa
4 changed files with 7 additions and 2 deletions

@ -2,5 +2,6 @@ pub(crate) mod context;
pub(crate) mod hunks;
pub(crate) mod inline;
pub(crate) mod json;
pub(crate) mod patch;
pub(crate) mod side_by_side;
pub(crate) mod style;

@ -10,7 +10,7 @@ use crate::{
parse::syntax::{AtomKind, MatchKind, MatchedPos, TokenKind},
};
fn split_lines_keep_newline(s: &str) -> Vec<&str> {
pub(crate) fn split_lines_keep_newline(s: &str) -> Vec<&str> {
lazy_static! {
static ref NEWLINE_RE: Regex = Regex::new("\n").unwrap();
}

@ -314,6 +314,7 @@ fn main() {
print_diff_result(&display_options, &diff_result);
}
DisplayMode::Json => display::json::print(&diff_result),
DisplayMode::Patch => display::patch::print(&diff_result),
}
}
}
@ -881,6 +882,7 @@ fn print_diff_result(display_options: &DisplayOptions, summary: &DiffResult) {
);
}
DisplayMode::Json => unreachable!(),
DisplayMode::Patch => todo!(),
}
}
(FileContent::Binary, FileContent::Binary) => {

@ -158,7 +158,7 @@ fn app() -> clap::Command<'static> {
)
.arg(
Arg::new("display").long("display")
.possible_values(["side-by-side", "side-by-side-show-both", "inline", "json"])
.possible_values(["side-by-side", "side-by-side-show-both", "inline", "json", "patch"])
.default_value("side-by-side")
.value_name("MODE")
.env("DFT_DISPLAY")
@ -300,6 +300,7 @@ When multiple overrides are specified, the first matching override wins."))
#[derive(Debug, Copy, Clone)]
pub(crate) enum DisplayMode {
Inline,
Patch,
SideBySide,
SideBySideShowBoth,
Json,
@ -570,6 +571,7 @@ pub(crate) fn parse_args() -> Mode {
DisplayMode::Json
}
"patch" => DisplayMode::Patch,
_ => {
unreachable!("clap has already validated display")
}