Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options which allows us to use difft as Apache Subversion's external diff tool #562

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ fn app() -> clap::Command<'static> {
.validator(|s| s.parse::<u32>())
.required(false),
)
.arg(
// Dummy 'unified' flag of POSIX/GNU diff utility for svn support:
// This takes no effect.
Arg::new("nop_unified")
.short('u')
.hide(true)
)
.arg(
Arg::new("label").short('L')
.long("label")
.takes_value(true)
.value_name("LABEL")
.max_occurrences(2)
.allow_invalid_utf8(true)
.help("Label of file(s) which should be used for printing instead of PATH(s).")
)
.arg(
Arg::new("width")
.long("width")
Expand Down Expand Up @@ -740,7 +756,25 @@ pub(crate) fn parse_args() -> Mode {
[lhs_path, rhs_path] => {
let lhs_arg = FileArgument::from_cli_argument(lhs_path);
let rhs_arg = FileArgument::from_cli_argument(rhs_path);
let display_path = build_display_path(&lhs_arg, &rhs_arg);
let display_path = if matches.is_present("label") {
let labels: Vec<_> = matches.values_of_os("label").unwrap_or_default().collect();
let (_lhs_display_path, rhs_display_path) = match &labels[..] {
[lhs_display_path, rhs_display_path] => (
lhs_display_path.to_string_lossy().to_string(),
rhs_display_path.to_string_lossy().to_string(),
),
[display_path] => (
display_path.to_string_lossy().to_string(),
display_path.to_string_lossy().to_string(),
),
_ => {
unreachable!("clap has already validated label")
}
};
rhs_display_path
} else {
build_display_path(&lhs_arg, &rhs_arg)
};

let lhs_permissions = lhs_arg.permissions();
let rhs_permissions = rhs_arg.permissions();
Expand Down
Loading