You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am not sure whether this is the right place but I spent a bit of time trying to wrap my head around how to write a completion function for rmapi https://github.com/juruen/rmapi but it does not work yet.
This is how far I came so far:
#compdef rmapi_rmapi_remote_files() {
local remfiles remdispf remdispd ret=1 pfx='\^/' sub='^/' suf expl
curdir=${words[CURRENT]%/*}# current string up to before /*
remfiles=(${(f)"$(_call_program files rmapi ls $IPREFIX${${PREFIX%%[^/]#}/#$pfx/$sub}| grep '^\[(d|f)\]'| sed -r 's|^\[d\]\s*(.+)|\1/|'| sed -r 's|^\[f\]\s*(.+)|\1|')"})
compset -P '*/'
compset -S '/*'|| suf=file
remdispf=(${remfiles:#*/})
remdispd=(${(M)remfiles:#*/})
_tags files
while _tags;dowhile _next_label files expl ${suf:-directory};do# add files, unless there is a '/' immediately to the right
[[ -n$suf ]] &&
compadd -S ''"$@""$expl[@]" -d remdispf -- $remdispf&& ret=0
# add directories; use empty suffix if there is a '/' immediately to the right
compadd "${suf:+-S /}""$@""$expl[@]" -d remdispd -- ${remdispd%/}&& ret=0
done(( ret ))||return 0
donereturn 1
}
_rmapi() {
local context state line
typeset -A opt_args
# -C allows to change curcontext
_arguments -C \
'1:cmd:->cmds' \
'*:: :->args' \
&& ret=0
case"$state"in
(cmds)
local commands; commands=(
'put:upload''get:download''mget:download directory''ls:list'
)
_describe -t commands 'command' commands && ret=0
;;
(args)
case$words[1] in
ls)
_rmapi_remote_files
;;
get)
_alternative "files:file:_rmapi_remote_files"
;;
mget)
_arguments "-o[output directory]:file:_files -/""*:: :_rmapi_remote_files"
;;
put)
_files -g "*.(pdf|epub)"
;;
esacesac
}
_rmapi "$@"
Now I struggle with getting suggestions for the remote files, the output of rmapi ls some/directory/ is of this form
[f] some_file
[f] A File with Spaces in Name
[d] directory
which should then result in the correct remdispf and remdispd.
But I do not really wrap my head around what happens after this (I simply tried to copy it from svn and or _remote_files) or does not as only completion of the commands works (and local files) but not remote.
If someone could help with that it would be amazing (also it would be nice to be able to use "-/" to only get directories like with files.
The text was updated successfully, but these errors were encountered:
Hi, I am not sure whether this is the right place but I spent a bit of time trying to wrap my head around how to write a completion function for rmapi https://github.com/juruen/rmapi but it does not work yet.
This is how far I came so far:
Now I struggle with getting suggestions for the remote files, the output of
rmapi ls some/directory/
is of this formwhich should then result in the correct remdispf and remdispd.
But I do not really wrap my head around what happens after this (I simply tried to copy it from svn and or _remote_files) or does not as only completion of the commands works (and local files) but not remote.
If someone could help with that it would be amazing (also it would be nice to be able to use "-/" to only get directories like with files.
The text was updated successfully, but these errors were encountered: