diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-11-26 19:28:01 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-11-26 19:28:01 +0100 |
commit | 8093b027ce0b23f5f377e23fa0fce4889dda6547 (patch) | |
tree | 7e11fea7c0bdf5c2e4cc0a4cb46698bfa47dcb0f | |
parent | 40cb22fb40e01f92fc4d7511e23ca1a3c21ae29c (diff) |
pkg: Added debug options
-rwxr-xr-x | bin/pkg | 18 | ||||
-rw-r--r-- | man/1/pkg | 4 | ||||
-rw-r--r-- | man/5/pkg.conf | 4 |
3 files changed, 26 insertions, 0 deletions
@@ -24,6 +24,21 @@ info=$'\e[0;36m' error=$'\e[0;31m' reset=$'\e[0m' +function debug { + if (( !DEBUG )) || (( SILENT )); then return; fi + typeset func line + if [[ ${#*} -ge 3 ]] { + func=$1 + line=$2 + shift 2 + } + echo "(debug) $func:$line: $*" +} + +# I need function name and line number of the function _calling_ debug, +# so I can't get them from inside the debug function. +alias debug='debug ${(%)$(echo %N)} ${(%)$(echo %i)}' + function info { (( SILENT )) || echo -ne "${info}$*${reset}" } @@ -65,6 +80,7 @@ if [[ -f $HOME/.pkg.conf ]] { : ${PDIR:="$HOME/packages"} : ${CL_OPTIONS:=-q} : ${SILENT=0} +: ${DEBUG=0} : ${AUTOUPDATE=1} export PDIR @@ -79,6 +95,8 @@ while [[ $1 == [-+]* ]] { case $1 in -q|--quiet) SILENT=1 ;; +q|--no-quiiet) SILENT=0 ;; + -d|--debug) DEBUG=1 ;; + +d|--no-debug) DEBUG=0 ;; -au|--auto-update) AUTOUPDATE=1 ;; +au|--no-auto-update) AUTOUPDATE=0 ;; -co|--checklinks-options) CL_OPTIONS+=$1; shift ;; @@ -96,6 +96,10 @@ Options always override the configuration file and the environment variables. Enable quiet mode, don't print progress. Useful for scripting +=item B<-d>, B<--debug> [boolean] + +Enable debug mode + =item B<-au>, B<--auto-update> [boolean] Automatically update the package list before doing certain actions diff --git a/man/5/pkg.conf b/man/5/pkg.conf index e4a0ab8..b508807 100644 --- a/man/5/pkg.conf +++ b/man/5/pkg.conf @@ -36,6 +36,10 @@ Options to invoke L<checklinks>(1) with Operate in silent mode if 1 +=item B<DEBUG>=I<boolean> (0) + +Operate in debug mode if 1 + =item B<AUTOUPDATE>=I<boolean> (1) If 1, automatically execute 'pkg update' before 'pkg push' |