mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
Update zsh completion for new help format
This commit is contained in:
parent
2d2f786bc1
commit
246275eed2
@ -4,14 +4,13 @@
|
||||
# it into your zsh function path (/usr/share/zsh/site-functions for
|
||||
# instance)
|
||||
#
|
||||
# Copyright (C) 2005 Steve Borho
|
||||
# Copyright (C) 2005-6 Steve Borho
|
||||
# Copyright (C) 2006-8 Brendan Cully <brendan@kublai.com>
|
||||
#
|
||||
# This is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
|
||||
emulate -LR zsh
|
||||
setopt extendedglob
|
||||
@ -117,28 +116,54 @@ _hg_cache_policy() {
|
||||
_hg_get_commands() {
|
||||
typeset -ga _hg_cmd_list
|
||||
typeset -gA _hg_alias_list
|
||||
local hline cmd cmdalias
|
||||
_call_program help hg --verbose help | while read -A hline
|
||||
local hline cmd cmdalias helpstate
|
||||
local helpmode=$1
|
||||
|
||||
_call_program help hg --verbose help $helpmode 2>/dev/null | while read -A hline
|
||||
do
|
||||
cmd="$hline[1]"
|
||||
case $cmd in
|
||||
*:)
|
||||
cmd=${cmd%:}
|
||||
_hg_cmd_list+=($cmd)
|
||||
;;
|
||||
*,)
|
||||
cmd=${cmd%,}
|
||||
_hg_cmd_list+=($cmd)
|
||||
integer i=2
|
||||
while (( i <= $#hline ))
|
||||
do
|
||||
cmdalias=${hline[$i]%(:|,)}
|
||||
_hg_cmd_list+=($cmdalias)
|
||||
_hg_alias_list+=($cmdalias $cmd)
|
||||
(( i++ ))
|
||||
done
|
||||
;;
|
||||
esac
|
||||
if [ "$hline" = "list of commands:" ]
|
||||
then
|
||||
helpstate="commands"
|
||||
continue
|
||||
elif [ "$hline" = "enabled extensions:" ]
|
||||
then
|
||||
helpstate="extensions"
|
||||
continue
|
||||
elif [ "$hline" = "additional help topics:" ]
|
||||
then
|
||||
helpstate="topics"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$helpstate" = commands ]
|
||||
then
|
||||
cmd="$hline[1]"
|
||||
case $cmd in
|
||||
*:)
|
||||
cmd=${cmd%:}
|
||||
_hg_cmd_list+=($cmd)
|
||||
;;
|
||||
*,)
|
||||
cmd=${cmd%,}
|
||||
_hg_cmd_list+=($cmd)
|
||||
integer i=2
|
||||
while (( i <= $#hline ))
|
||||
do
|
||||
cmdalias=${hline[$i]%(:|,)}
|
||||
_hg_cmd_list+=($cmdalias)
|
||||
_hg_alias_list+=($cmdalias $cmd)
|
||||
(( i++ ))
|
||||
done
|
||||
;;
|
||||
esac
|
||||
elif [ -z "$helpmode" -a "$helpstate" = extensions ]
|
||||
then
|
||||
cmd="$hline[1]"
|
||||
if [ -n "$cmd" ]
|
||||
then
|
||||
_hg_get_commands $cmd
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user