summary refs log tree commit diff
path: root/bin/mega
diff options
context:
space:
mode:
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}" $@