From 7834fb442dd0565a74e6f69027f082b65f439fca Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Wed, 19 Sep 2018 10:06:41 +0300 Subject: [PATCH] flip writing made easier --- code/app.py | 2 +- code/templates/flip | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/code/app.py b/code/app.py index a692359..5bcd053 100644 --- a/code/app.py +++ b/code/app.py @@ -14,7 +14,7 @@ from utils.utils import * from utils.crypt import * -__FLEES_VERSION__ = "20180918.0" +__FLEES_VERSION__ = "20180919.0" app = Flask(__name__) app.config.from_object(__name__) config_values = read_config(app) diff --git a/code/templates/flip b/code/templates/flip index 3e475f1..1c9f4d1 100755 --- a/code/templates/flip +++ b/code/templates/flip @@ -13,8 +13,8 @@ _help() { (w)rite Save to clipboard, read from stdin/file/folder (d)elete Delete an entry url Get the direct share url - upload Get URL for uploads - update Update flip client + upload Get URL for uploads [no arguments] + update Update flip client [no arguments] Name: Any string for the clipboard name. default: 0 @@ -27,6 +27,7 @@ _help() { Shorthand: echo my data | $SELF 1 # writes data with name: 1 $SELF 1 | cat - # prints the contents of file: 1 + $SELF w file.ext # sends file keeping its name Config: set: FLEES_ROOTURL, FLEES_SHARE, FLEES_TOKEN @@ -57,8 +58,14 @@ _list() { } _write() { - # no file mentioned, use stdin - [[ -z "$FILE" ]] && stream_in=1 + # no file mentioned, use the name as file + [[ -z "$FILE" ]] && { + [[ -e "$NAME" ]] && { + # NAME is actually the file, reverse roles + FILE="$NAME" + NAME=$( basename "$NAME" ) + } + } # stdin is open, use stdin [ -t 0 ] || stream_in=1 @@ -192,4 +199,3 @@ _get_file _url "$NAME" exit $? } -