Skip to content

Commit 5dc6738

Browse files
Feature: Add a --debug option to help troubleshooting
1 parent 9eb2817 commit 5dc6738

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

diff-so-fancy

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ if ($args->{color_on}) {
5353
$color_forced = 1;
5454
}
5555

56+
if ($args->{debug}) {
57+
show_debug_info();
58+
exit();
59+
}
60+
5661
# `git add --patch` requires our output to match the number of lines from the
5762
# input. So, when patch mode is active, we print out empty lines to pad our
5863
# output to match any lines we've consumed.
@@ -924,4 +929,31 @@ sub get_terminal_width {
924929
return $width;
925930
}
926931

932+
sub show_debug_info {
933+
my $git_ver = trim(`git --version`);
934+
$git_ver =~ s/[^\d.]//g;
935+
936+
print "Diff-so-fancy : v$VERSION\n";
937+
print "Git : v$git_ver\n";
938+
print "Perl : $^V\n";
939+
print "\n";
940+
941+
print "Supports Unicode: " . yes_no(should_print_unicode()) . "\n";
942+
print "Unicode Ruler : " . yes_no($use_unicode_dash_for_ruler) . "\n";
943+
print "Terminal width : " . get_terminal_width() . "\n";
944+
print "Terminal \$LANG : " . $ENV{LANG} . "\n";
945+
print "Is Windows : " . yes_no(is_windows()) . "\n";
946+
print "Operating System: $^O\n";
947+
}
948+
949+
sub yes_no {
950+
my $val = shift();
951+
952+
if ($val) {
953+
return "Yes";
954+
} else {
955+
return "No";
956+
}
957+
}
958+
927959
# vim: tabstop=4 shiftwidth=4 noexpandtab autoindent softtabstop=4

0 commit comments

Comments
 (0)