-
Notifications
You must be signed in to change notification settings - Fork 7
/
mdev
executable file
·56 lines (48 loc) · 1.49 KB
/
mdev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -e
trap 'error "$(printf "Command \`%s\` at $BASH_SOURCE:$LINENO failed with exit code $?" "$BASH_COMMAND")"' ERR
## find directory where this script is located following symlinks if necessary
readonly MDEV_DIR="$(
cd "$(
dirname "$(
(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")
)"
)" >/dev/null \
&& pwd
)"
readonly MDEV="$MDEV_DIR/$(basename ${BASH_SOURCE[0]})"
source "${MDEV_DIR}/bin/include/base.sh"
## parse first argument as command and determine validity
if (( "$#" )); then
## local project directory if running within one; don't fail if it can't be found
if [[ -f "${MDEV_DIR}/bin/${1}" ]]; then
COMMAND="${1}"
shift
if [[ "${1}" == "help" ]] || [[ "${1}" == "--help" ]]; then
${MDEV_DIR}/m help $COMMAND || exit $? && exit $?
fi
source "${MDEV_DIR}/bin/${COMMAND}";
else
echo "No command found"
fi
else
bold=$(tput bold)
end=$(tput sgr0)
echo -e "\033[35m
.__ __. Welcome to _
| \/ | __ _ __ _ ___ _ __ | |_ ___
| |\/| |/ _\` |/ _\` |/ _ \ :_ \| __/ \\
| | | | ( | | (_| | __/ | | | || ( ) |
|_| |_|\__,_|\__, |\___|_| |_|\__\___/
|___/ ${bold}DevBox${end} v.1.0 ...
\033[0m"
echo "
Run ${bold}mdev${end} [command] to execute commend
or ${bold}mdev${end} help [command] to get help
List of available commands:"
for f in ${MDEV_DIR}/bin/* ; do
if [ -f $f ]; then
echo -e " \033[32m$(basename $f)${end}"
fi;
done
fi