flip copy/paste a file
This commit is contained in:
@@ -13,7 +13,7 @@ from revprox import ReverseProxied
|
|||||||
from utils import *
|
from utils import *
|
||||||
|
|
||||||
|
|
||||||
__FLEES_VERSION__ = "20191020.0"
|
__FLEES_VERSION__ = "20191024.0"
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(__name__)
|
app.config.from_object(__name__)
|
||||||
config_values = read_config(app)
|
config_values = read_config(app)
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ _help() {
|
|||||||
(r)ead Read from clipboard, write to stdout or file
|
(r)ead Read from clipboard, write to stdout or file
|
||||||
(w)rite Save to clipboard, read from stdin/file/folder
|
(w)rite Save to clipboard, read from stdin/file/folder
|
||||||
(d)elete Delete an entry
|
(d)elete Delete an entry
|
||||||
|
(c)opy Copy file/folder
|
||||||
|
(p)aste Paste file/folder (will overwrite)
|
||||||
url Get the direct share url
|
url Get the direct share url
|
||||||
upload Get URL for uploads [no arguments]
|
upload Get URL for uploads [no arguments]
|
||||||
update Update flip client [no arguments]
|
update Update flip client [no arguments]
|
||||||
@@ -71,6 +73,32 @@ _simple_list() {
|
|||||||
printf "\n"
|
printf "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_copy() {
|
||||||
|
# stdin is open
|
||||||
|
[ -t 0 ] || stream_in=1
|
||||||
|
# no file mentioned, use the name as file
|
||||||
|
[[ -z "$FILE" ]] && {
|
||||||
|
FILE="$NAME"
|
||||||
|
}
|
||||||
|
NAME=file.tar
|
||||||
|
[[ -e "$FILE" ]] && {
|
||||||
|
# Input file exists, dont use stream
|
||||||
|
stream_in=0
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ $stream_in -ne 1 ]] && [[ -z "$FILE" ]] && {
|
||||||
|
_msg File to read needed, or use stdin
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
_msg "Writing $NAME"
|
||||||
|
[[ "$stream_in" -eq 1 ]] && {
|
||||||
|
_write_stdin "$NAME"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
_write_folder "$NAME" "$FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_write() {
|
_write() {
|
||||||
# stdin is open
|
# stdin is open
|
||||||
[ -t 0 ] || stream_in=1
|
[ -t 0 ] || stream_in=1
|
||||||
@@ -116,6 +144,17 @@ _write_stdin() { # name
|
|||||||
cat - | curl -L -F "file=@-;filename=$1" "${FLEES_ROOTURL}upload/${FLEES_SHARE}/${FLEES_TOKEN}"
|
cat - | curl -L -F "file=@-;filename=$1" "${FLEES_ROOTURL}upload/${FLEES_SHARE}/${FLEES_TOKEN}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_paste() {
|
||||||
|
[[ "$NAME" = "-" ]] && stream_out=1
|
||||||
|
[[ -d "$NAME" ]] && cd "$NAME"
|
||||||
|
[ -t 1 ] || stream_out=1
|
||||||
|
[[ "$stream_out" -eq 1 ]] && {
|
||||||
|
_read_stdout "file.tar"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_read_stdout "file.tar" | tar xv
|
||||||
|
}
|
||||||
|
|
||||||
_read() {
|
_read() {
|
||||||
[[ "$FILE" = "-" ]] && stream_out=1
|
[[ "$FILE" = "-" ]] && stream_out=1
|
||||||
[ -t 1 ] || stream_out=1
|
[ -t 1 ] || stream_out=1
|
||||||
@@ -197,7 +236,7 @@ _get_completer() {
|
|||||||
local curr_arg
|
local curr_arg
|
||||||
curr_arg=${COMP_WORDS[COMP_CWORD]}
|
curr_arg=${COMP_WORDS[COMP_CWORD]}
|
||||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||||
COMPREPLY=( $(compgen -W "help autocomplete list read write delete url update upload self" -- $curr_arg ) );
|
COMPREPLY=( $(compgen -W "help autocomplete list copy paste read write delete url update upload self" -- $curr_arg ) );
|
||||||
fi
|
fi
|
||||||
if [[ $COMP_CWORD -eq 2 ]]; then
|
if [[ $COMP_CWORD -eq 2 ]]; then
|
||||||
case ${COMP_WORDS[$(( $COMP_CWORD - 1 ))]} in
|
case ${COMP_WORDS[$(( $COMP_CWORD - 1 ))]} in
|
||||||
@@ -205,7 +244,7 @@ if [[ $COMP_CWORD -eq 2 ]]; then
|
|||||||
local remotelist=$( eval FLIP_EXEC simplelist )
|
local remotelist=$( eval FLIP_EXEC simplelist )
|
||||||
COMPREPLY=( $(compgen -W "$remotelist" -- $curr_arg ) );
|
COMPREPLY=( $(compgen -W "$remotelist" -- $curr_arg ) );
|
||||||
;;
|
;;
|
||||||
w*)
|
w*|c*|p*)
|
||||||
COMPREPLY=( $(compgen -f -d -- $curr_arg ) );
|
COMPREPLY=( $(compgen -f -d -- $curr_arg ) );
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -239,6 +278,8 @@ CMD=list
|
|||||||
[[ "$1" = "w" || "$1" = "write" ]] && { CMD=write; ARG1=$CMD; }
|
[[ "$1" = "w" || "$1" = "write" ]] && { CMD=write; ARG1=$CMD; }
|
||||||
[[ "$1" = "d" || "$1" = "delete" || "$1" = "del" ]] && { CMD=delete; ARG1=$CMD; }
|
[[ "$1" = "d" || "$1" = "delete" || "$1" = "del" ]] && { CMD=delete; ARG1=$CMD; }
|
||||||
[[ "$1" = "l" || "$1" = "list" ]] && { CMD=list; ARG1=$CMD; }
|
[[ "$1" = "l" || "$1" = "list" ]] && { CMD=list; ARG1=$CMD; }
|
||||||
|
[[ "$1" = "c" || "$1" = "copy" ]] && { CMD=copy; ARG1=$CMD; }
|
||||||
|
[[ "$1" = "p" || "$1" = "paste" ]] && { CMD=paste; ARG1=$CMD; }
|
||||||
[[ "$1" = "simplelist" ]] && { CMD=simple_list; ARG1=$CMD; }
|
[[ "$1" = "simplelist" ]] && { CMD=simple_list; ARG1=$CMD; }
|
||||||
[[ "$1" = "autocomplete" ]] && { _get_completer; }
|
[[ "$1" = "autocomplete" ]] && { _get_completer; }
|
||||||
[[ "$1" = "url" ]] && { CMD=url; ARG1=$CMD; }
|
[[ "$1" = "url" ]] && { CMD=url; ARG1=$CMD; }
|
||||||
@@ -263,6 +304,10 @@ _get_file
|
|||||||
_read
|
_read
|
||||||
exit $?
|
exit $?
|
||||||
}
|
}
|
||||||
|
[[ "$CMD" = copy ]] && {
|
||||||
|
_copy
|
||||||
|
exit $?
|
||||||
|
}
|
||||||
[[ "$CMD" = delete ]] && {
|
[[ "$CMD" = delete ]] && {
|
||||||
_delete "$NAME"
|
_delete "$NAME"
|
||||||
exit $?
|
exit $?
|
||||||
@@ -271,6 +316,10 @@ _get_file
|
|||||||
_write
|
_write
|
||||||
exit $?
|
exit $?
|
||||||
}
|
}
|
||||||
|
[[ "$CMD" = paste ]] && {
|
||||||
|
_paste
|
||||||
|
exit $?
|
||||||
|
}
|
||||||
[[ "$CMD" = url ]] && {
|
[[ "$CMD" = url ]] && {
|
||||||
_url "$NAME"
|
_url "$NAME"
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
Reference in New Issue
Block a user