zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Add openSUSE specific command completions
@ 2011-04-20 13:49 İsmail Dönmez
  2011-04-26 12:09 ` İsmail Dönmez
  2011-04-30 16:59 ` Peter Stephenson
  0 siblings, 2 replies; 7+ messages in thread
From: İsmail Dönmez @ 2011-04-20 13:49 UTC (permalink / raw)
  To: zsh-workers


[-- Attachment #1.1: Type: text/plain, Size: 145 bytes --]

Hi;

These completions were getting rot in openSUSE zsh package. It would be nice
to get them included upstream.

Thanks,
İsmail DÖNMEZ

[-- Attachment #1.2: Type: text/html, Size: 222 bytes --]

[-- Attachment #2: suse-completion.patch --]
[-- Type: text/x-patch, Size: 11109 bytes --]

commit 227c70c794b87f23207ebc9eb5cccf5ed89ac241
Author: İsmail Dönmez <ismail@namtrac.org>
Date:   Wed Apr 20 15:32:54 2011 +0200

    Add command completion for openSUSE tools: hwinfo, osc, SuSEconfig,
    yast2, zypper

diff --git a/Completion/openSUSE/Command/_SuSEconfig b/Completion/openSUSE/Command/_SuSEconfig
new file mode 100644
index 0000000..d508285
--- /dev/null
+++ b/Completion/openSUSE/Command/_SuSEconfig
@@ -0,0 +1,28 @@
+#compdef SuSEconfig
+
+local curcontext="$curcontext" state line
+typeset -A opt_args
+
+if [[ -z "$_SuSEconfig_modules" ]]; then 
+	for i in /sbin/conf.d/SuSEconfig.*; do
+		case $i in *.rpm*|*.swap|*.bak|*.orig|*~|\#*) continue;; esac
+		_SuSEconfig_modules=($_SuSEconfig_modules ${i##*/SuSEconfig.})
+	done
+fi
+
+
+_arguments \
+  '--help' \
+  '--quick' \
+  '--force' \
+  '--verbose' \
+  '--nonewpackage' \
+  '--module:module:->module' && return 0
+
+case $state in
+	module) compadd $_SuSEconfig_modules ;;
+esac
+
+# Usage: SuSEconfig [--quick|--nonewpackage|--force|--verbose] [--module name]
+
+
diff --git a/Completion/openSUSE/Command/_hwinfo b/Completion/openSUSE/Command/_hwinfo
new file mode 100644
index 0000000..aac0a05
--- /dev/null
+++ b/Completion/openSUSE/Command/_hwinfo
@@ -0,0 +1,79 @@
+#compdef hwinfo
+
+_arguments \
+  '--help[show usage info]' \
+  '--version[show libhd version]' \
+  '--short[just a short listing]' \
+  '--log[write info to logfile]:logfile:_files' \
+  '--debug[set debuglevel]:debuglevels:(1 2 3 4 5 6 7 8 9)' \
+  '--dump-db[dump hardware data base, 0: external, 1: internal]:dumpdb:(0 1)' \
+  '--bios' \
+  '--block' \
+  '--bluetooth' \
+  '--braille' \
+  '--bridge' \
+  '--camera' \
+  '--cdrom' \
+  '--chipcard' \
+  '--cpu' \
+  '--disk' \
+  '--dsl' \
+  '--dvb' \
+  '--floppy' \
+  '--framebuffer' \
+  '--gfxcard' \
+  '--hub' \
+  '--ide' \
+  '--isapnp' \
+  '--isdn' \
+  '--joystick' \
+  '--keyboard' \
+  '--memory' \
+  '--modem' \
+  '--monitor' \
+  '--mouse' \
+  '--netcard' \
+  '--network' \
+  '--partition' \
+  '--pci' \
+  '--pcmcia' \
+  '--pcmcia-ctrl' \
+  '--pppoe' \
+  '--printer' \
+  '--scanner' \
+  '--scsi' \
+  '--smp' \
+  '--sound' \
+  '--storage-ctrl' \
+  '--sys' \
+  '--tape' \
+  '--tv' \
+  '--usb' \
+  '--usb-ctrl' \
+  '--vbe' \
+  '--wlan' \
+  '--zip' \
+  '--all' \
+  '--reallyall' && return 0
+
+
+# hwinfo-9.31-1.1
+#
+# Usage: hwinfo [options]
+# Probe for hardware.
+#   --short        just a short listing
+#   --log logfile  write info to logfile
+#   --debug level  set debuglevel
+#   --version      show libhd version
+#   --dump-db n    dump hardware data base, 0: external, 1: internal
+#   --hw_item      probe for hw_item
+#   hw_item is one of:
+#     all, bios, block, bluetooth, braille, bridge, camera, cdrom, chipcard, cpu,
+#     disk, dsl, dvb, floppy, framebuffer, gfxcard, hub, ide, isapnp, isdn,
+#     joystick, keyboard, memory, modem, monitor, mouse, netcard, network,
+#     partition, pci, pcmcia, pcmcia-ctrl, pppoe, printer, scanner, scsi, smp,
+#     sound, storage-ctrl, sys, tape, tv, usb, usb-ctrl, vbe, wlan, zip
+# 
+#   Note: debug info is shown only in the log file. (If you specify a
+#   log file the debug level is implicitly set to a reasonable value.)
+
diff --git a/Completion/openSUSE/Command/_osc b/Completion/openSUSE/Command/_osc
new file mode 100644
index 0000000..2808f92
--- /dev/null
+++ b/Completion/openSUSE/Command/_osc
@@ -0,0 +1,149 @@
+#compdef osc
+#
+# Copyright (C) 2009,2010 Holger Macht <holger@homac.de>
+#
+# This file is released under the GPLv2.
+#
+# Based on the the zsh guide from http://zsh.dotsrc.org/Guide/zshguide06.html
+#
+# Toggle verbose completions: zstyle ':completion:*:osc:*' verbose no
+#                             zstyle ':completion:*:osc-subcommand:*' verbose no
+# 
+# Use the variables $ZSH_OSC_BUILD_TARGETS_EXTRA and $ZSH_OSC_PROJECTS_EXTRA to
+# extend the list of possible completions in your ~/.zshrc like that:
+#  export OSC_PROJECTS_EXTRA="Base:System Base:shells"
+#
+# version 0.2
+#
+
+OSC_BUILD_TARGETS="openSUSE_10.2 openSUSE_10.3 openSUSE_11.0 openSUSE_11.1 openSUSE_11.2 openSUSE_11.3 openSUSE_Factory"
+OSC_PROJECTS="openSUSE:Factory openSUSE:11.2 openSUSE:11.3 openSUSE:11.1 openSUSE:11.0 openSUSE:10.3"
+
+# user defined variables $OSC_BUILD_TARGETS_EXTRA and
+# $OSC_PROJECTS_EXTRA can add to the project/build target list
+OSC_BUILD_TARGETS="$OSC_BUILD_TARGETS $ZSH_OSC_BUILD_TARGETS_EXTRA"
+OSC_PROJECTS="$OSC_PROJECTS $ZSH_OSC_PROJECTS_EXTRA"
+
+# Main dispatcher
+
+_osc() {
+    if (( CURRENT > 2 )) && [[ ${words[2]} != "help" ]]; then
+        # Remember the subcommand name
+	local cmd=${words[2]}
+        # Set the context for the subcommand.
+	curcontext="${curcontext%:*:*}:osc-subcommand"
+        # Narrow the range of words we are looking at to exclude `osc'
+	(( CURRENT-- ))
+	shift words
+        # Run the completion for the subcommand
+	if [ "$cmd" = "submitreq" -o "$cmd" = "sr" ]; then
+	    _osc_cmd_submitreq
+	elif [ "$cmd" = "getbinaries" ]; then
+	    _osc_cmd_getbinaries
+	elif [ "$cmd" = "checkout" -o "$cmd" = "co" -o "$cmd" = "branch" ]; then
+	    _osc_cmd_checkout
+	elif [ "$cmd" = "buildlog" -o "$cmd" = "buildinfo" -o "$cmd" = "bl" ]; then
+	    _osc_cmd_buildlog
+	else
+	    _osc_cmd_do $cmd
+	fi
+    else
+	local hline
+	local -a cmdlist
+	local tag=0
+	_call_program help-commands osc help | while read -A hline; do
+	    # start parsing with "commands:"
+	    [[ $hline[1] = "commands:" ]] && tag=1
+	    # stop parsing at the line starting with "For"
+	    [[ $hline[1] = "For" ]] && tag=0
+	    [[ $tag = 0 ]] && continue
+	    # all commands have to start with lower case letters
+	    [[ $hline[1] =~ ^[A-Z] ]] && continue
+	    (( ${#hline} < 2 )) && continue
+
+    	    # ${hline[1]%,} truncates the last ','
+	    cmdlist=($cmdlist "${hline[1]%,}:${hline[2,-1]}")
+	done
+	_describe -t osc-commands 'osc command' cmdlist
+    fi
+}
+
+_osc_cmd_getbinaries() {
+    _arguments \
+	'1:PROJECT:( `echo $OSC_PROJECTS` )' \
+	'2:PACKAGE:(PACKAGE)' \
+	'3:REPOSITORY:( `echo $OSC_BUILD_TARGETS` )' \
+	'4:ARCHITECTURE:(i586 x86_64)'
+}
+
+_osc_cmd_checkout() {
+    _arguments \
+	'1:PROJECT:( `echo $OSC_PROJECTS` )' \
+	'2:PACKAGE:(PACKAGE)'
+}
+
+_osc_cmd_buildlog() {
+    _arguments \
+	'1:REPOSITORY:( `echo $OSC_BUILD_TARGETS` )' \
+	'2:ARCHITECTURE:(i586 x86_64)'
+}
+
+_osc_cmd_submitreq() {
+    local hline
+    local -a cmdlist
+    local tag=0
+    _call_program help-commands osc help $cmd | while read -A hline; do
+        # start parsing from "usage:"
+	[[ $hline[1] = "usage:" ]] && tag=1
+	[[ $tag = 0 ]] && continue
+
+	if [[ $hline[1] =~ ^osc ]]; then
+	    shift hline; shift hline
+	elif ! [[ $hline[1] =~ ^- ]]; then
+            # Option has to start with a '-' or 'osc submitrequest'
+	    continue
+	fi
+
+	(( ${#hline} < 2 )) && continue
+
+	cmdlist=($cmdlist "${hline[1]%,}:${hline[2,-1]}")
+
+    done
+    
+    _describe -t osc-commands 'osc command' cmdlist
+}
+
+
+_osc_cmd_do() {
+    local hline
+    local -a cmdlist
+    local tag=0
+    
+    # only start completion if theres some '-' on the line
+    if ! [ "$words[2]" = "-" ]; then
+	_complete
+	return
+    fi
+
+    _call_program help-commands osc help $cmd | while read -A hline; do
+	# start parsing from "Options:"
+	[[ $hline[1] = "Options:" ]] && tag=1
+	[[ $tag = 0 ]] && continue
+	# Option has to start with a '-'
+	[[ $hline[1] =~ ^- ]] || continue
+	(( ${#hline} < 2 )) && continue
+
+	cmdlist=($cmdlist "${hline[1]%,}:${hline[2,-1]}")
+    done
+
+    if [ -n "$cmdlist" ]; then
+	_describe -t osc-commands 'osc command' cmdlist
+    else
+	_complete
+    fi
+}
+
+# Code to make sure _osc is run when we load it
+_osc "$@"
+
+
diff --git a/Completion/openSUSE/Command/_yast2 b/Completion/openSUSE/Command/_yast2
new file mode 100644
index 0000000..b9c7f24
--- /dev/null
+++ b/Completion/openSUSE/Command/_yast2
@@ -0,0 +1,30 @@
+#compdef yast2 yast
+
+local curcontext="$curcontext" state line
+typeset -A opt_args
+
+if [[ -z "$_yast2_modules" ]]; then 
+	for i in $(/sbin/yast2 --list | grep -v "Available.*modules"); do
+		_yast2_modules=($_yast2_modules $i)
+	done
+fi
+
+_arguments -s \
+  '(--list)-l[list all available modules]' '(-l)--list' \
+  '(--help)-h[help]' '(-h)--help'\
+  \
+ {'(--geometry)-g[default window size (qt only)]','(-g)--geometry'}':geometry:(800x600+0+0)' \
+  '(--style)-s[widget style (qt only)]' '(-s)--style' \
+  \
+ {'(--install)-i[install rpm package]','(-i)--install'}':filename:_files' \
+  \
+ '--noborder[no window manager border for main window]' '--noborder' \
+ '--fullscreen[use full screen]' '--fullscreen' \
+  \
+  ':module:->module' && return 0
+
+case $state in
+	module) compadd $_yast2_modules; _files -g "*.ycp";;
+esac
+
+
diff --git a/Completion/openSUSE/Command/_zypper b/Completion/openSUSE/Command/_zypper
new file mode 100644
index 0000000..57f942d
--- /dev/null
+++ b/Completion/openSUSE/Command/_zypper
@@ -0,0 +1,73 @@
+#compdef zypper
+#
+# Copyright (C) 2009 Holger Macht <holger@homac.de>
+#
+# This file is released under the GPLv2.
+#
+# Based on the the zsh guide from http://zsh.dotsrc.org/Guide/zshguide06.html
+#
+# Toggle verbose completions: zstyle ':completion:*:zypper:*' verbose no
+#                             zstyle ':completion:*:zypper-subcommand:*' verbose no
+#
+#  version 0.1
+#
+# Main dispatcher
+
+_zypper() {
+    if (( CURRENT > 2 )) && [[ ${words[2]} != "help" ]]; then
+        # Remember the subcommand name
+	local cmd=${words[2]}
+        # Set the context for the subcommand.
+	curcontext="${curcontext%:*:*}:zypper-subcommand"
+        # Narrow the range of words we are looking at to exclude `zypper'
+	(( CURRENT-- ))
+	shift words
+	
+	_zypper_cmd_do $cmd
+    else
+	local hline
+	local -a cmdlist
+	local tag=0
+	_call_program help-commands zypper help | while read -A hline; do
+	    # start parsing with "Global Options:"
+	    [[ $hline =~ "^Global Options:" ]] && tag=1
+	    [[ $tag = 0 ]] && continue
+	    [[ $hline[1] =~ ^\t\t\t\t ]] && continue
+	    # all commands have to start with lower case letters
+	    [[ $hline[1] =~ ^[A-Z] ]] && continue
+	    (( ${#hline} < 2 )) && continue
+
+	    # cut comma at end of command
+	    hline[1]=`echo $hline[1] | sed -e 's/\(^.*\),/\1/'`
+
+	    # ${hline[1]%,} truncates the last ','
+	    cmdlist=($cmdlist "${hline[1]%,}:${hline[2,-1]}")
+	done
+	_describe -t zypper-commands 'zypper command' cmdlist
+    fi
+}
+
+_zypper_cmd_do() {
+    local hline
+    local -a cmdlist
+    local tag=0
+    _call_program help-commands zypper help $cmd | while read -A hline; do
+	# start parsing from "Options:"
+	[[ $hline =~ "^Command options:" ]] && tag=1
+	[[ $tag = 0 ]] && continue
+	# Option has to start with a '-'
+	[[ $hline[1] =~ ^- ]] || continue
+	(( ${#hline} < 2 )) && continue
+
+	cmdlist=($cmdlist "${hline[1]%,}:${hline[2,-1]}")
+    done
+
+    if [ -n "$cmdlist" ]; then
+	_describe -t zypper-commands 'zypper command' cmdlist
+    else
+	_complete
+    fi
+}
+
+# Code to make sure _zypper is run when we load it
+_zypper "$@"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add openSUSE specific command completions
  2011-04-20 13:49 [PATCH] Add openSUSE specific command completions İsmail Dönmez
@ 2011-04-26 12:09 ` İsmail Dönmez
  2011-04-30 16:59 ` Peter Stephenson
  1 sibling, 0 replies; 7+ messages in thread
From: İsmail Dönmez @ 2011-04-26 12:09 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 223 bytes --]

Hi;

On Wed, Apr 20, 2011 at 3:49 PM, İsmail Dönmez <ismail@namtrac.org> wrote:

> Hi;
>
> These completions were getting rot in openSUSE zsh package. It would be
> nice to get them included upstream.
>

Ping?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add openSUSE specific command completions
  2011-04-20 13:49 [PATCH] Add openSUSE specific command completions İsmail Dönmez
  2011-04-26 12:09 ` İsmail Dönmez
@ 2011-04-30 16:59 ` Peter Stephenson
  2011-04-30 19:11   ` İsmail Dönmez
  2011-05-02  0:40   ` Benjamin R. Haskell
  1 sibling, 2 replies; 7+ messages in thread
From: Peter Stephenson @ 2011-04-30 16:59 UTC (permalink / raw)
  To: zsh-workers

On Wed, 20 Apr 2011 15:49:43 +0200
İsmail Dönmez <ismail@namtrac.org> wrote:
> These completions were getting rot in openSUSE zsh package. It would be nice
> to get them included upstream.

Thanks, just got back from holiday, skipped with glazed eyes over
zillions of emails but noticed this and committed it.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add openSUSE specific command completions
  2011-04-30 16:59 ` Peter Stephenson
@ 2011-04-30 19:11   ` İsmail Dönmez
  2011-05-02  0:40   ` Benjamin R. Haskell
  1 sibling, 0 replies; 7+ messages in thread
From: İsmail Dönmez @ 2011-04-30 19:11 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 456 bytes --]

Hi;

On Sat, Apr 30, 2011 at 6:59 PM, Peter Stephenson <
p.w.stephenson@ntlworld.com> wrote:

> On Wed, 20 Apr 2011 15:49:43 +0200
> İsmail Dönmez <ismail@namtrac.org> wrote:
> > These completions were getting rot in openSUSE zsh package. It would be
> nice
> > to get them included upstream.
>
> Thanks, just got back from holiday, skipped with glazed eyes over
> zillions of emails but noticed this and committed it.


Awesome, thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add openSUSE specific command completions
  2011-04-30 16:59 ` Peter Stephenson
  2011-04-30 19:11   ` İsmail Dönmez
@ 2011-05-02  0:40   ` Benjamin R. Haskell
  2011-05-02  7:06     ` İsmail Dönmez
  2011-05-02 11:48     ` Peter Stephenson
  1 sibling, 2 replies; 7+ messages in thread
From: Benjamin R. Haskell @ 2011-05-02  0:40 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

[-- Attachment #1: Type: TEXT/PLAIN, Size: 768 bytes --]

On Sat, 30 Apr 2011, Peter Stephenson wrote:

> On Wed, 20 Apr 2011 15:49:43 +0200 İsmail Dönmez wrote:
>> These completions were getting rot in openSUSE zsh package. It would 
>> be nice to get them included upstream.
>
> Thanks, just got back from holiday, skipped with glazed eyes over 
> zillions of emails but noticed this and committed it.

I noticed that a couple of those (_osc and _zypper) had copyright 
notices in the files (which didn't seem to match the submitter), and 
that they were "released under the GPLv2."

Are those okay to include without Zsh itself being GPL'ed?  I see the 
LICENCE file states that "any provisions made in individual files take 
precedence."  That makes it fine?

(Asking out of curiosity more than anything.)

-- 
Best,
Ben

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add openSUSE specific command completions
  2011-05-02  0:40   ` Benjamin R. Haskell
@ 2011-05-02  7:06     ` İsmail Dönmez
  2011-05-02 11:48     ` Peter Stephenson
  1 sibling, 0 replies; 7+ messages in thread
From: İsmail Dönmez @ 2011-05-02  7:06 UTC (permalink / raw)
  To: Benjamin R. Haskell; +Cc: Peter Stephenson, zsh-workers

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

Hi;

On Mon, May 2, 2011 at 2:40 AM, Benjamin R. Haskell <zsh@benizi.com> wrote:

> On Sat, 30 Apr 2011, Peter Stephenson wrote:
>
>
>  On Wed, 20 Apr 2011 15:49:43 +0200 İsmail Dönmez wrote:
>>
>>> These completions were getting rot in openSUSE zsh package. It would be
>>> nice to get them included upstream.
>>>
>>
>> Thanks, just got back from holiday, skipped with glazed eyes over zillions
>> of emails but noticed this and committed it.
>>
>
> I noticed that a couple of those (_osc and _zypper) had copyright notices
> in the files (which didn't seem to match the submitter), and that they were
> "released under the GPLv2."
>
> Are those okay to include without Zsh itself being GPL'ed?  I see the
> LICENCE file states that "any provisions made in individual files take
> precedence."  That makes it fine?
>
> (Asking out of curiosity more than anything.


I can ask the original authors to relicense if thats a problem.

Regards,
ismail

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add openSUSE specific command completions
  2011-05-02  0:40   ` Benjamin R. Haskell
  2011-05-02  7:06     ` İsmail Dönmez
@ 2011-05-02 11:48     ` Peter Stephenson
  1 sibling, 0 replies; 7+ messages in thread
From: Peter Stephenson @ 2011-05-02 11:48 UTC (permalink / raw)
  To: zsh-workers

On Sun, 1 May 2011 20:40:07 -0400 (EDT)
"Benjamin R. Haskell" <zsh@benizi.com> wrote:
> On Sat, 30 Apr 2011, Peter Stephenson wrote:
> 
> > On Wed, 20 Apr 2011 15:49:43 +0200 İsmail Dönmez wrote:
> >> These completions were getting rot in openSUSE zsh package. It would 
> >> be nice to get them included upstream.
> >
> > Thanks, just got back from holiday, skipped with glazed eyes over 
> > zillions of emails but noticed this and committed it.
> 
> I noticed that a couple of those (_osc and _zypper) had copyright 
> notices in the files (which didn't seem to match the submitter), and 
> that they were "released under the GPLv2."
> 
> Are those okay to include without Zsh itself being GPL'ed?  I see the 
> LICENCE file states that "any provisions made in individual files take 
> precedence."  That makes it fine?

I'm not aware of it being a problem in shell functions, at least.
Typically it's after compilation where we need to be particularly
careful.  We already have GNU functions for configuration etc., although
that's a special case.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-05-02 11:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 13:49 [PATCH] Add openSUSE specific command completions İsmail Dönmez
2011-04-26 12:09 ` İsmail Dönmez
2011-04-30 16:59 ` Peter Stephenson
2011-04-30 19:11   ` İsmail Dönmez
2011-05-02  0:40   ` Benjamin R. Haskell
2011-05-02  7:06     ` İsmail Dönmez
2011-05-02 11:48     ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).