#!/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}" $@