summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2022-08-21 15:57:29 +0200
committerLevente Polyak <anthraxx@archlinux.org>2022-08-23 20:23:51 +0200
commitba070f1ca9b0dd60567a61c0c3cdb287165246be (patch)
treeebe9b68e37d62bd080c06d7d026b322de40a24e5 /src
parentb9dadc55760642ac4e8ac9766cf832cc38015923 (diff)
downloaddevtools-ba070f1ca9b0dd60567a61c0c3cdb287165246be.tar.xz
diffpkg: add colored output option with default of auto
Diffstat (limited to 'src')
-rw-r--r--src/diffpkg.in14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/diffpkg.in b/src/diffpkg.in
index 243e127..ce8b030 100644
--- a/src/diffpkg.in
+++ b/src/diffpkg.in
@@ -28,6 +28,8 @@ usage() {
-h, --help Show this help text
OUTPUT OPTIONS
+ --color[=WHEN] Color output; WHEN is 'never', 'always', or 'auto';
+ Plain --color means --color='auto'
-u, -U, --unified Output 3 lines of unified context
-y, --side-by-side Output in two columns
@@ -47,6 +49,7 @@ PKGINFO=0
BUILDINFO=0
DIFFMODE=--side-by-side
+DIFFCOLOR=--color
DIFFOPTIONS=(--expand-tabs)
# option checking
@@ -88,6 +91,15 @@ while (( $# )); do
DIFFMODE=--side-by-side
shift
;;
+ --color|--color=*)
+ if [[ $2 == never || $2 == always || $2 == auto ]]; then
+ DIFFCOLOR="--color=$2"
+ shift 2
+ continue
+ fi
+ DIFFCOLOR="$1"
+ shift
+ ;;
--)
shift
break
@@ -108,7 +120,7 @@ if (( VERBOSE )); then
else
DIFFOPTIONS+=(--suppress-common-lines)
fi
-DIFFOPTIONS+=("${DIFFMODE}")
+DIFFOPTIONS+=("${DIFFMODE}" "${DIFFCOLOR}")
if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then
TARLIST=1