summary refs log tree commit diff
path: root/bin/mega
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2020-01-26 17:16:07 +0100
committerRobert Günzler <r@gnzler.io>2020-01-26 18:00:59 +0100
commitf5d56602df70950de6b7d40966b00c9939c81763 (patch)
treeb50ffeb5496fe3525cc1bab2629389ced95435b7 /bin/mega
Intial commit of v2
See https://drewdevault.com/2019/12/30/dotfiles.html
Diffstat (limited to 'bin/mega')
-rwxr-xr-xbin/mega33
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/mega b/bin/mega
new file mode 100755
index 0000000..b59ebe5
--- /dev/null
+++ b/bin/mega
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# little convenience wrapper around the mega cli tools
+#
+
+usage() {
+    echo "usage: mega -u USER -p PASSWD COMMAND"
+    echo ""
+    exit 0
+}
+
+while getopts ":hu:p:" o; do
+    case $o in
+        u)
+            user=${OPTARG} ;;
+        p)
+            passwd=${OPTARG} ;;
+        h | *)
+            usage ;;
+    esac
+done
+shift $((OPTIND - 1))
+
+[ -z "$1" ] || [ -z "$user" ] || [ -z "$passwd" ] && usage
+if ! command -v ${1} &>/dev/null; then
+    echo "error: ${1} not installed." >&2
+    exit 1
+else
+    cmd=$1
+fi
+shift
+
+exec "mega${cmd}" -u "${user}" -p "${passwd}" $@