-
Notifications
You must be signed in to change notification settings - Fork 0
/
xop
executable file
·98 lines (87 loc) · 2.56 KB
/
xop
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
#
# Title: devenv
# Description: Master script for managing development environment
# Developer: ddnomad
# Version: 0.0.1
set -eu -o pipefail
source ./xopos/bash/utils/messenger.util
# NotImplementedError
print_error 'Error: work in progress functionality'
print_error_and_exit 1 'This script is not ready for a prime time (yet)'
# -----------------------------------------------------------------------
readonly ROOT_INFO_NAME="$(basename "$0")"
readonly ROOT_INFO_USER="$(who | cut -f1 -d ' ')"
readonly ROOT_INFO_DISTRO="$(grep -x "ID=.*" </etc/os-release | cut -f2 -d '=')"
readonly ROOT_MSG_ERR_UNSUF_ARGS='Error: unsufficient number of arguments: '
readonly ROOT_MSG_ERR_NOPT='Error: unknown option: '
readonly ROOT_MSG_HELP="$(cat <<EOF
Usage: ${ROOT_INFO_NAME} [-h] [MODULE] [MODULE OPTIONS] args
Manage development environment configuration and workflow.
Currently supported functions include:
* Install host dependencies (Vagrant, Virtualbox)
* TODO: append subcommands functionality
Most functions are exposed via respective subcommands. A list
of all supported subcommands and their respective options are
available below.
OPTIONS
-h --help Print this message and exit
-c --no-color Disable colored output
-i --install-deps Install host dependencies
MODULES
TODO: append subcommands help messages
EOF
)"
###############################################################
# Print help message of a master script and exit if requested
#
# Arguments:
# $1 [optional] - exit code if exit is necessary
#
# Return:
# None
#
# Terminates:
# Yes
###############################################################
function print_help {
local exit
exit=false
if [[ "$#" -eq 1 ]]; then
exit="$1"
fi
__print 'PLAIN' "${exit}" "${ROOT_MSG_HELP}"
}
###
# Import subcommands
####
function import_subs {
true
}
##########################################################
# Resolve arguments and pass control flow to subcommands
#
# Arguments:
# $@ - all arguments of the scripts
#
# Return:
# None
#
# Terminates:
# Yes
##########################################################
function resolver {
case "$1" in
-h | --help ) print_help 0 ;;
-c | --no-color ) MESSENGER_OUTPUT_COLOR=false ;;
-e | --no-stderr ) MESSENGER_OUTPUT_NOSTDERR=true ;;
-* ) print_error "${ROOT_MSG_ERR_NOPT}$1" && print_help 1 ;;
esac
}
##### MAIN FLOW #####
if [[ "$#" -lt 1 ]]; then
print_error "${ROOT_MSG_ERR_UNSUF_ARGS}0"
print_help 1
fi
import_subs
resolver "$@"