autocomplete for flip
This commit is contained in:
@@ -16,6 +16,7 @@ _help() {
|
||||
upload Get URL for uploads [no arguments]
|
||||
update Update flip client [no arguments]
|
||||
self Get URL to install this client to another computer
|
||||
autocomplete Get Bash autocompletion script
|
||||
|
||||
Name: Any string for the clipboard name. default: 0
|
||||
|
||||
@@ -58,6 +59,11 @@ _list() {
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
_simple_list() {
|
||||
curl -s "$FLEES_ROOTURL/file/list/$FLEES_SHARE/$FLEES_TOKEN"
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
_write() {
|
||||
# no file mentioned, use the name as file
|
||||
[[ -z "$FILE" ]] && {
|
||||
@@ -163,6 +169,35 @@ _get_file() {
|
||||
return 0
|
||||
}
|
||||
|
||||
_get_completer() {
|
||||
self=$( basename $( readlink -f "$0" ) )
|
||||
echo '_flip_complete() {
|
||||
local curr_arg
|
||||
curr_arg=${COMP_WORDS[COMP_CWORD]}
|
||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||
COMPREPLY=( $(compgen -W "help autocomplete list read write delete url update upload self" -- $curr_arg ) );
|
||||
fi
|
||||
if [[ $COMP_CWORD -eq 2 ]]; then
|
||||
case ${COMP_WORDS[$(( $COMP_CWORD - 1 ))]} in
|
||||
r*|url|d*)
|
||||
local remotelist=$( eval FLIP_EXEC simplelist )
|
||||
COMPREPLY=( $(compgen -W "$remotelist" -- $curr_arg ) );
|
||||
;;
|
||||
w*)
|
||||
COMPREPLY=( $(compgen -f -d -- $curr_arg ) );
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [[ $COMP_CWORD -eq 3 ]]; then
|
||||
COMPREPLY=( $(compgen -f -d -- $curr_arg ) );
|
||||
fi
|
||||
}
|
||||
complete -F _flip_complete FLIP_EXEC
|
||||
# Run me as: source <( FLIP_EXEC autocomplete )
|
||||
' | sed "s,FLIP_EXEC,$self,"
|
||||
exit 0
|
||||
}
|
||||
|
||||
_load_config
|
||||
for (( i=1; i<=$#; i++ )); do
|
||||
[[ "${!i}" = "-h" ]] && _help
|
||||
@@ -182,6 +217,8 @@ CMD=list
|
||||
[[ "$1" = "w" || "$1" = "write" ]] && { CMD=write; ARG1=$CMD; }
|
||||
[[ "$1" = "d" || "$1" = "delete" || "$1" = "del" ]] && { CMD=delete; ARG1=$CMD; }
|
||||
[[ "$1" = "l" || "$1" = "list" ]] && { CMD=list; ARG1=$CMD; }
|
||||
[[ "$1" = "simplelist" ]] && { CMD=simple_list; ARG1=$CMD; }
|
||||
[[ "$1" = "autocomplete" ]] && { _get_completer; }
|
||||
[[ "$1" = "url" ]] && { CMD=url; ARG1=$CMD; }
|
||||
[[ "$1" = "update" ]] && { _update_client; }
|
||||
[[ "$1" = "upload" ]] && { _upload_url; }
|
||||
@@ -193,6 +230,11 @@ CMD=list
|
||||
exit $?
|
||||
}
|
||||
|
||||
[[ "$CMD" = simple_list ]] && {
|
||||
_simple_list
|
||||
exit $?
|
||||
}
|
||||
|
||||
_get_name
|
||||
_get_file
|
||||
[[ "$CMD" = read ]] && {
|
||||
|
||||
Reference in New Issue
Block a user