zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _bzr
@ 2005-09-06 16:06 Clint Adams
  2005-09-09 10:26 ` Oliver Kiddle
  0 siblings, 1 reply; 5+ messages in thread
From: Clint Adams @ 2005-09-06 16:06 UTC (permalink / raw)
  To: zsh-workers

Completion for bzr 0.0.7.

Index: Completion/Unix/Command/_bzr
===================================================================
RCS file: Completion/Unix/Command/_bzr
diff -N Completion/Unix/Command/_bzr
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_bzr	6 Sep 2005 16:05:45 -0000
@@ -0,0 +1,11 @@
+#compdef bzr
+
+local _bzr_subcommands expl curcontext="$curcontext"
+
+_bzr_subcommands=(${(f)"$(_call_program bzr bzr shell-complete)"})
+
+if (( CURRENT == 2 )); then
+  _describe -t subcommand 'subcommand' _bzr_subcommands
+else
+# this part missing
+fi


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

* Re: PATCH: _bzr
  2005-09-06 16:06 PATCH: _bzr Clint Adams
@ 2005-09-09 10:26 ` Oliver Kiddle
  2005-09-09 13:48   ` Clint Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 2005-09-09 10:26 UTC (permalink / raw)
  To: zsh-workers

On 6 Sep, Clint Adams wrote:
> Completion for bzr 0.0.7.

> +else
> +# this part missing
> +fi

If you are going to leave a part missing like that, it probably makes
sense to complete files there. Unless bzr never takes filenames as an
argument. Breaking filename completion is really quite bad because it
can put users off compsys completely.

Oliver


This message has been scanned for viruses by MailControl - www.mailcontrol.com


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

* Re: PATCH: _bzr
  2005-09-09 10:26 ` Oliver Kiddle
@ 2005-09-09 13:48   ` Clint Adams
  2006-03-28 23:07     ` Wayne Davison
  0 siblings, 1 reply; 5+ messages in thread
From: Clint Adams @ 2005-09-09 13:48 UTC (permalink / raw)
  To: zsh-workers

> If you are going to leave a part missing like that, it probably makes
> sense to complete files there. Unless bzr never takes filenames as an
> argument. Breaking filename completion is really quite bad because it
> can put users off compsys completely.

Done, with clarification.

Index: Completion/Unix/Command/_bzr
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_bzr,v
retrieving revision 1.1
diff -u -r1.1 _bzr
--- Completion/Unix/Command/_bzr	6 Sep 2005 16:08:29 -0000	1.1
+++ Completion/Unix/Command/_bzr	9 Sep 2005 13:47:52 -0000
@@ -7,5 +7,7 @@
 if (( CURRENT == 2 )); then
   _describe -t subcommand 'subcommand' _bzr_subcommands
 else
-# this part missing
+# this part should call bzr shell-complete <subcmd> when
+# it has been tweaked properly
+  _files
 fi


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

* Re: PATCH: _bzr
  2005-09-09 13:48   ` Clint Adams
@ 2006-03-28 23:07     ` Wayne Davison
  2006-03-29  0:04       ` Clint Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Wayne Davison @ 2006-03-28 23:07 UTC (permalink / raw)
  To: zsh-workers

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

There's another _bzr completion function available that was in the bzr
repository (in the contrib/zsh subdir).  This one is more complete than
what we have, so I refined it quite a bit, and then checked it in.

Since many of you folks are much better at completion functions than me,
please feel free to give it a look and see if it can't be improved even
more.  I'll attach it to this message to make it easy to review...

..wayne..

[-- Attachment #2: _bzr --]
[-- Type: text/plain, Size: 7524 bytes --]

#compdef bzr

# bzr is the bazaar-ng revision-control system

local curcontext="$curcontext" state line expl cmd args ret=1
typeset -A opt_args

_arguments -C \
    '1: :->cmd' \
    '*:: :->args' && ret=0

if (( ! $+_bzr_cmds )); then
    typeset -gH _bzr_cmds
    _bzr_cmds=(${(f)"$(_call_program bzr bzr shell-complete)"})
fi

if [[ $state != 'args' ]]; then
    _describe -t subcommand 'subcommand' _bzr_cmds
    return 0
fi

cmd="$words[1]"
curcontext="${curcontext%:*:*}:bzr-$cmd:"

(( $+functions[_bzr_unknownFiles] )) ||
_bzr_unknownFiles() {
    local fileList
    fileList=(${(ps:\0:)"$(bzr ls --null --unknown)"})
    compadd -af fileList
    return 0
}

(( $+functions[_bzr_unknownRoot] )) ||
_bzr_unknownRoot() {
    local fileList
    fileList=(${(ps:\0:)"$(bzr ls --null --from-root --unknown)"})
    compadd -af fileList
    return 0
}

(( $+functions[_bzr_versionedFiles] )) ||
_bzr_versionedFiles() {
    local fileList
    fileList=(${(ps:\0:)"$(bzr ls --null --versioned)"})
    compadd -af fileList
    return 0
}

(( $+functions[_bzr_completeParents] )) ||
_bzr_completeParents() {
    local parentFile=$(bzr root 2>/dev/null)/.bzr/parent
    [[ -r $parentFile ]] && compadd -X "Completing parents" $(cat $parentFile)
}

args=( '(-)'{--help,-h}'[show help message]' )

case $cmd in
(add)
    args+=(
	'--no-recurse[do not recurse into subdirectories]'
	'(-q --quiet)'{--quiet,-q}'[be quiet]'
	'*:unknown files:_bzr_unknownFiles'
	)
    ;;

(annotate|praise|blame)
    args+=( '*:files:_bzr_versionedFiles' )
    ;;

(clone|branch|get)
    args+=(
	'(-r --revision)'{--revision,-r}'[revision]:rev:'
	'--basis[specify basis branch]:basis:'
	)
    if (( CURRENT == 2 )); then
	args+=( '*:FROM_LOCATION:_files -/' )
    elif (( CURRENT == 3 )); then
	args+=( '*:TO_LOCATION:_files -/' )
    fi
    ;;

(rename|mv)
    if (( CURRENT == 2 )); then
	args+=( '*:old name:_bzr_versionedFiles' )
    else
	args+=( '*:new name:' )
    fi
    ;;

(cat)
    args+=(
	'(-r --revision)'{--revision,-r}'[revision]:rev:'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(root)
    args+=( '*:file:_files' )
    ;;

(log)
    args+=(
	'(-r --revision)'{--revision,-r}'[revision or range]:rev or rev range:'
	'(-v --verbose)'{--verbose,-v}'[show revision manifest]'
	'(-l --short --long)'{--long,-l}'[use long format (default)]'
	'(-l --long)--short[use short format]'
	'(-m --message)'{--message,-m}'[specify regexp]:regexp:'
	'--show-ids[show file IDs]'
	'--forward[reverse direction of revisions]'
	'--timezone[specify timezone for dates]:timezone:'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(resolve)
    args+=(
	'--all[resolve all conflicts in this tree]'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(status|st|stat)
    args+=(
	'--all[include unchanged versioned files]'
	'--show-ids[show file IDs]'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(check)
    args+=(
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'*:DIR:_files -/'
	)
    ;;

(mkdir|upgrade|renames)
    args+=( '*:DIR:_files -/' )
    ;;

(remove|rm)
    args+=(
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(pull)
    args+=(
	'--remember[Remember the specified location as a default]'
	'--overwrite[Ignore differences, overwrite unconditionally]'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(missing)
    args+=(
	'(-v --verbose -q --quiet)'{--verbose,-v}'[display more information]'
	'(-q --quiet -v --verbose)'{--quiet,-q}'[be quiet]'
	'(-l --long --short --log_format)--line[Use log format with one line per revision. Same as "--log-format line"]'
	'(-l --long --short --line)--log-format[Use the specified log format]:log format'
	'(-l --long --short --line --log-format)'{--long,-l}'[Use detailed log format. Same as "--log-format long"]'
	'--mine-only[Display changes in the local branch only]'
	'--reverse[Reverse the order of revisions]'
	'(-l --long --log_format)--short[Use moderately short log format. Same as "--log-format short"]'
	'--show-ids[show internal object ids]'
	'--theirs-only[Display changes in the remote branch only]'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(commit|checkin|ci)
    args+=(
	'(-m --message)'{--message,-m}'[commit message]:message text:'
	'(-F --file)'{--file,-F}'[commit message from file]:message file:'
	'--unchanged[include unchanged files]'
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'*:modified files:_bzr_versionedFiles'
	)
    ;;

(conflicts|added|deleted|modified|unknowns|directories|ignored)
    ;;

(revno|init|version)
    ;;

(whoami)
    args+=( '--email[only show e-mail address]' )
    ;;

(inventory)
    args+=(
	'(-r --revision)'{--revision,-r}'[show inventory of a revision]:revision:'
	'--show-ids[show file IDs]'
	)
    ;;

(diff|dif|di)
    args+=(
	'(-r --revision)'{--revision,-r}'[revision]:revision:'
	'--diff-options[options to pass to gdiff]:diff options:'
	'*:files:_files'
	)
    ;;

(export)
    args+=(
	'(-r --revision)'{--revision,-r}'[revision]:revision:'
	'--format=[format of exported file]:format:(dir tar tgz tbz2)'
	'--root[root directory of patch]:_files -/'
	'*:destination:_files'
	)
    ;;

(ignore)
    args+=( '*:NAME_PATTERN:_bzr_unknownRoot' )
    ;;

(info)
    args+=( '*:branch:_files -/' )
    ;;

(testament)
    args+=(
	'(-r --revision)'{--revision,-r}'[revision]:revision:'
	'(-l --long)'{--long,-l}'[use long format]'
	'*:branch:_files -/'
	)
    ;;

(revert|merge-revert)
    args+=(
	'(-r --revision)'{--revision,-r}'[revision]:revision:'
	'--no-backup[skip generation of backup~ files]'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(merge)
    args+=(
	'(-r --revision)'{--revision,-r}'[revision]:revision:'
	'--reprocess[Reprocess to reduce spurious conflicts]'
	'--show-base[Show base revision text in conflicts]'
	'--force[ignore uncommitted changes]'
	'--merge-type:merge type:(diff3 merge3 weave)'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(ls)
    args+=(
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'(-r --revision)'{--revision,-r}'[revision]:revision:'
	'--from-root[Print all paths from the root of the branch]'
	'--non-recursive[Do not recurse into subdirectories]'
	'--null[Null separate the files]'
	'--ignored[Print ignored files]'
	'--unknown[Print unknown files]'
	'--versioned[Print versioned files]'
	)
    ;;

(move)
    if (( CURRENT == 2 )); then
	args+=(
	   '*:files:_bzr_versionedFiles'
	   )
    else
	args=(
	    '*:destination dir:_files -/'
	    )
    fi
    ;;

(help)
    args=(
	'(-l --long)'{--long,-l}'[use long format]'
	'*:subcmds:->cmds'
	)
    _arguments -s "$args[@]" && ret=0
    _describe -t subcommand 'subcommand' _bzr_cmds
    return 0
    ;;

    # Plugins

(visualize|visualise|viz|vis)
    args+=( '(-r --revision)'{--revision,-r}'[starting revision]:rev:' )
    ;;

(gannotate|gblame|gpraise)
    args+=(
	'--all[show annotations on all lines]'
	'--plain[do not hightlight annotation lines]'
	'*:files:_bzr_versionedFiles'
	)
    ;;

(push)
    args+=(
	'--overwrite[Ignore differences, overwrite unconditionally]'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(clean-tree)
    args+=(
	'--dry-run[show files to delete instead of deleting them]'
	'--ignored[delete all ignored files]'
	'--detritus[delete conflict files, merge backups, failed self-tests, *~, *.tmp, etc]'
	)
    ;;

(*)
    _message "unknown bzr command completion: $cmd"
    return 1
    ;;
esac

_arguments -s "$args[@]" && ret=0
return ret

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

* Re: PATCH: _bzr
  2006-03-28 23:07     ` Wayne Davison
@ 2006-03-29  0:04       ` Clint Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Clint Adams @ 2006-03-29  0:04 UTC (permalink / raw)
  To: zsh-workers

> Since many of you folks are much better at completion functions than me,
> please feel free to give it a look and see if it can't be improved even
> more.  I'll attach it to this message to make it easy to review...

In case anyone else is interested in this, the original intent of the
bzr shell-complete subcmd was to output completion info for each
subcmd.  For example:

% bzr s-c add
--no-recurse
--dry-run
--verbose
file*

There was supposed to be some rewrite of the options parsing code to
allow shell-complete to output instead of 'file*', either a line that
could be passed directly to _arguments or something that could be
transformed easily.

Finishing this might be a fun project for someone who uses bzr and can
stand Python.


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

end of thread, other threads:[~2006-03-29  0:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-06 16:06 PATCH: _bzr Clint Adams
2005-09-09 10:26 ` Oliver Kiddle
2005-09-09 13:48   ` Clint Adams
2006-03-28 23:07     ` Wayne Davison
2006-03-29  0:04       ` Clint Adams

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).