From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28855 invoked by alias); 14 Nov 2011 04:35:25 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16578 Received: (qmail 448 invoked from network); 14 Nov 2011 04:35:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_MED,T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 128.2.11.95 is neither permitted nor denied by SPF record at _spf.google.com) Date: Sun, 13 Nov 2011 20:13:19 -0800 From: gi1242+zsh@gmail.com To: zsh-users@zsh.org Subject: lp completion update Message-ID: <20111114041319.GB6041@andrew.cmu.edu> Mail-Followup-To: gi1242+zsh@gmail.com, zsh-users@zsh.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-PMX-Version: 5.5.9.388399, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.5.19.222118 X-SMTP-Spam-Clean: 34% ( RDNS_SUSP_FORGED_FROM 3.5, FORGED_FROM_GMAIL 0.1, MIME_TEXT_ONLY_MP_MIXED 0.05, BODYTEXTP_SIZE_3000_LESS 0, NO_REAL_NAME 0, NO_URI_FOUND 0, RDNS_GENERIC_POOLED 0, RDNS_SUSP 0, RDNS_SUSP_GENERIC 0, __CD 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __FRAUD_CONTACT_NAME 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_MSGID 0, __LINES_OF_YELLING 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __PHISH_SPEAR_ACCOUNT_1 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __USER_AGENT 0) X-SMTP-Spam-Score: 34% X-Scanned-By: MIMEDefang 2.60 on 128.2.11.95 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Attached patch adds completion for lpadmin and lpinfo, and fixes some minor bugs. GI -- 100 THINGS I'D DO IF I EVER BECAME AN EVIL OVERLORD 100. Finally, to keep my subjects permanently locked in a mindless trance, I will provide each of them with free unlimited Internet access. --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lp.diff" diff --git a/Completion/Unix/Command/_lp b/Completion/Unix/Command/_lp index def9aed..f05fded 100644 --- a/Completion/Unix/Command/_lp +++ b/Completion/Unix/Command/_lp @@ -1,9 +1,9 @@ -#compdef lp lpr lpq lprm lpoptions lpstat +#compdef lp lpr lpq lprm lpoptions lpstat lpinfo lpadmin _lp_get_printer() { - # No reason to call _lp_get_printer when service == lpstat. Others matched - # below. + # No reason to call _lp_get_printer when service == lpstat or lpinfo. Others + # matched below. case $service in (lpr|lpq|lprm) [[ "$words" == (#I)*-P* ]] && printer="${${words##*(#I)-P( |)}%% *}" @@ -11,6 +11,9 @@ _lp_get_printer() (lp) [[ "$words" == (#I)*-d* ]] && printer="${${words##*(#I)-d( |)}%% *}" ;; + (lpadmin) + [[ "$words" == (#I)*-p* ]] && printer="${${words##*(#I)-p( |)}%% *}" + ;; (lpoptions) [[ "$words" == (#I)*-(d|p)* ]] && \ printer="${${words##*(#I)-(d|p)( |)}%% *}" @@ -29,6 +32,13 @@ _lp_job_options() lopts_no_args=(fitplot landscape) + if [[ $service == 'lpadmin' ]]; then + # Extra options from lpadmin man page. + lopts_with_args+=(cupsIPPSupplies cupsSNMPSupplies job-k-limit + job-page-limit job-quota-period job-sheets-default name name-default + port-monitor printer-error-policy printer-is-shared printer-op-policy) + fi + _lp_get_printer [[ -n "$printer" ]] && printer=(-p $printer) @@ -53,6 +63,12 @@ _lp_job_options() (scaling|cpi|lpi|page-(bottom|left|right|top)) return 0; # Don't complete anything ;; + (cupsIPPSupplies|cupsSNMPSupplies|printer-is-shared) + compadd "$@" true false + ;; + (printer-error-policy) + compadd "$@" abort-job retry-job retry-current-job stop-printer + ;; (*) compadd "$@" \ $(_call_program list-printer-options lpoptions $printer -l | \ @@ -133,7 +149,7 @@ _lp() case $service in (lpq) _arguments \ - '-E[force encryption]' \ + '-E[Force encryption]' \ '-U:username (for connection to server):_users' \ '-h:alternate server:_hosts' \ '(-a)-P+[destination printer]:printers:_printers' \ @@ -144,7 +160,7 @@ _lp() (lprm) _arguments \ - '-E[force encryption]' \ + '-E[Force encryption]' \ '-U:username (for connection to server):_users' \ '-h:alternate server:_hosts' \ '-P+[destination printer]:printers:_printers' \ @@ -153,74 +169,109 @@ _lp() (lpoptions) _arguments \ - '-E[force encryption]' \ + '-E[Force encryption]' \ '-U:username (for connection to server):_users' \ '-h:alternate server:_hosts' \ - '(-p -l -r -x)-d[set default printer]:printers:_printers' \ + '(-p -l -r -x)-d+[set default printer]:printers:_printers' \ '(-l -x)*-o:job options:_lp_job_options' \ - '(-d -x)-p[destination printer for options]:printers:_printers' \ + '(-d -x)-p+[destination printer for options]:printers:_printers' \ '(-d -o -r -x)-l[list options]' \ '(-d -l -x)*-r:remove option:_lp_job_options' \ - '(-d -l -r -o)-x[remove all options]:printers:_printers' + '(-d -l -r -o)-x+[remove all options]:printers:_printers' ;; (lpstat) _arguments \ - '-E[force encryption]' \ - '-R[shows print job ranking]' \ + '-E[Force encryption]' \ + '-R[Shows print job ranking]' \ '-U:username (for connection to server):_users' \ '-W:which jobs:(completed not-completed)' \ - '-a[show accepting state]:printers:_printers' \ + '-a+[Show accepting state]:printers:_printers' \ '-c:printer classes:' \ - '-d[show current default destination]' \ + '-d[Show current default destination]' \ '-h:hostname (alternate server):_hosts' \ '-l[long listing]' \ - '-o[destinations]:printers:_printers' \ - '-p:printers:_printers' \ + '-o+[destinations]:printers:_printers' \ + '-p+:printers:_printers' \ '-r[CUPS server running status]' \ - '-s[status summary]' \ - '-t[all status info]' \ + '-s[Status summary]' \ + '-t[All status info]' \ '-u[list jobs by users]:users:_users' \ - '-v[show devices]:printers:_printers' + '-v+[show devices]:printers:_printers' ;; (lpr) _arguments \ - '-E[force encryption]' \ + '-E[Force encryption]' \ '-H:hostname (alternate server):_hosts' \ '(-C -J -T)'-{C,J,T}':job name:' \ '-P+[destination printer]:printers:_printers' \ '-U:username (for connection to server):_users' \ - '-#[copies]:copies (1--100):' \ - '-h[disables banner printing]' \ + '-#[Copies]:copies (1--100):' \ + '-h[Disables banner printing]' \ '-l[raw file]' \ - '-m[send an email on job completion]' \ + '-m[Send an email on job completion]' \ '*-o:print job options:_lp_job_options' \ '-p[format with shaded header incl. date, time etc.]' \ - '-q[hold job for printing]' \ + '-q[Hold job for printing.]' \ '-r[delete files after printing]' \ '*:PS/PDF files:_pspdf' ;; (lp) _arguments \ - '-E[force encryption]' \ + '-E[Force encryption]' \ '-U[username (for connection to server)]:username:_users' \ '-c[(OBSOLETE) copy to spool dir before printing]' \ - '-d[destination printer]:printers:_printers' \ + '-d+[destination printer]:printers:_printers' \ '-h:hostname (alternate server):_hosts' \ '-i[job id to modify]:job id:' \ - '-m[send an email on job completion]' \ - '-n[copies]:copies (1--100):' \ + '-m[Send an email on job completion]' \ + '-n[Copies]:copies (1--100):' \ '*-o:print job options:_lp_job_options' \ - '-q[job priority -- 1 (lowest) to 100 (highest)]:priority:' \ - '-s[dont report resulting job IDs]' \ - '-t[sets the job name]:job name:' \ + '-q[Job priority -- 1 (lowest) to 100 (highest)]:priority:' \ + '-s[Dont report resulting job IDs]' \ + '-t[Sets the job name]:job name:' \ '-u[job submission username]:username:_users' \ - '-H[time to print]:print time (or enter hh\:mm):(hold immediate restart resume)' \ + '-H[Time to print]:print time (or enter hh\:mm):(hold immediate restart resume)' \ '-P:page range list:' \ '*:PS/PDF files:_pspdf' ;; + + (lpinfo) + _arguments \ + '-E[Force encryption]' \ + '-U[username (for connection to server)]:username:_users' \ + '-h:hostname (alternate server):_hosts' \ + '-l[Shows a "long" listing of devices or drivers]' \ + {--exclude-schemes,--include-schemes}'[device/PPD schemes to filter from results]:scheme-list:' \ + '(-v --timeout)--device-id[IEEE-1284 device ID to match]:device-id-string:' \ + '(-v --timeout)--language:locale:' \ + '(-v --timeout)--product[product to match]:name:' \ + '(-v --timeout)--make-and-model[make and model to match]:name:' \ + '(-v --timeout)-m[list available drivers]' \ + '(-m --device-id --language --make-and-model --product)--timeout[timeout when listing devices with -v]:timeout (seconds):' \ + '(-m --device-id --language --make-and-model --product)-v[list available devices]' + ;; + + (lpadmin) + _arguments \ + '-E[Force encryption/Enable destination]' \ + '-U[username (for connection to server)]:username:_users' \ + '-h:hostname (alternate server):_hosts' \ + '(-p -R -x -o)-d+[default printer]:printers:_printers' \ + '(-d -x)-p+[configure printer]:printers:_printers' \ + '(-p -R -d -o)-x+[delete printer]:printers:_printers' \ + '(-x -d)-R[name-default]:name-default:' \ + '-c:printer classes:' \ + '-m:model:' \ + '(-x -d)*-o:options:_lp_job_options' \ + '-r[remove from class]:class:' \ + '-u[access policy]:access policy:' \ + '-v[device-uri of printer queue]:device-uri:' \ + '-D[Text description of destination]:info:' \ + '-L[Location of the printer]:location:' \ + '-P[PPD file to use]:PPD file:_files "*.(#i)ppd(-.)"' esac } --3V7upXqbjpZ4EhLz--