Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit 66efd53

Browse files
committed
Major migration of CLI to /cli
1 parent e4a83cb commit 66efd53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+146
-114
lines changed

api/README.md

Lines changed: 1 addition & 0 deletions

bin/box

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin/box

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
#
3+
# @todo: http://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
4+
#
5+
6+
source /opt/box/cli/includes/functions
7+
source /opt/box/cli/includes/constants
8+
source "${WPLIB_BOX_COLORS_FILE}"
9+
10+
#
11+
#
12+
#if [[ "$1" != "set-user-name" && "$1" != "set-user-email" ]];then
13+
#
14+
# verify_user_config || error=1
15+
#
16+
#fi
17+
18+
if [ "" == "${error}" ];then
19+
20+
if [ "$1" == "" ]; then
21+
export WPLIB_BOX_COMMAND="help"
22+
else
23+
export WPLIB_BOX_COMMAND="$1"
24+
fi
25+
26+
command_file="${WPLIB_BOX_COMMANDS_DIR}/${WPLIB_BOX_COMMAND}"
27+
28+
if [ "${WPLIB_BOX_COMMAND}" == "help" ]; then
29+
source "${command_file}"
30+
#check_updates_available "$*"
31+
echo 1>&2
32+
exit
33+
fi
34+
35+
if [ -f "${command_file}" ]; then
36+
command_type="bash"
37+
else
38+
if [ -f "${command_file}.php" ]; then
39+
command_type="php"
40+
else
41+
echo 1>&2
42+
echo -e "\tCommand not found: $1" 1>&2
43+
echo 1>&2
44+
exit
45+
fi
46+
fi
47+
48+
initial_dir=$(pwd)
49+
error=0
50+
case "${command_type}" in
51+
"bash")
52+
shift
53+
source "${command_file}" "$@"
54+
error=$?
55+
;;
56+
"php")
57+
shift
58+
59+
/usr/bin/php7.0 "${WPLIB_BOX_INCLUDES_DIR}/run-command.php" --args "${WPLIB_BOX_COMMAND}" "$@"
60+
error=$?
61+
;;
62+
esac
63+
cd "${initial_dir}"
64+
65+
fi
66+
67+
if [[ $error -ne 0 ]]; then
68+
echo -e "\t" 1>&2
69+
echo "The '$1' command terminated WITH ERRORS." 1>&2
70+
echo -e "\t" 1>&2
71+
exit 1
72+
fi
73+
74+
#check_updates_available "$*"

box

Lines changed: 0 additions & 74 deletions
This file was deleted.

box

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/box

cli/README.md

Lines changed: 1 addition & 0 deletions
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# Pull the complete list of WPLib container packages from Docker Hub into local JSON files.
77
# Manage containers - stop/start and most importantly creating containers using the embedded JSON string in the image.
88

9+
source /opt/box/cli/includes/functions
10+
source /opt/box/cli/includes/constants
911

1012
DEFAULT_PROJECT="wplib"
1113

@@ -222,21 +224,21 @@ d_exists()
222224
d_update()
223225
{
224226
echo -n "$ECHO_PREFIX ${GREEN}Updating repository list${RESET}."
225-
if [ ! -d /opt/box/etc ]
227+
if [ ! -d ${WPLIB_BOX_BASE_DIR}/etc ]
226228
then
227-
sudo mkdir -p /opt/box/etc
229+
sudo mkdir -p ${WPLIB_BOX_BASE_DIR}/etc
228230
fi
229-
if [ ! -d /opt/box/etc/images ]
231+
if [ ! -d ${WPLIB_BOX_BASE_DIR}/etc/images ]
230232
then
231-
sudo mkdir -p /opt/box/etc/images
233+
sudo mkdir -p ${WPLIB_BOX_BASE_DIR}/etc/images
232234
fi
233235

234-
sudo wget -qNO /opt/box/etc/respositories.json https://hub.docker.com/v2/repositories/$DEFAULT_PROJECT/?page_size=256
235-
IMAGES="`jq -r '.results|.[]|.name' /opt/box/etc/respositories.json`"
236+
sudo wget -qNO ${WPLIB_BOX_BASE_DIR}/etc/respositories.json https://hub.docker.com/v2/repositories/$DEFAULT_PROJECT/?page_size=256
237+
IMAGES="`jq -r '.results|.[]|.name' ${WPLIB_BOX_BASE_DIR}/etc/respositories.json`"
236238
for IMAGE_NAME in $IMAGES
237239
do
238240
echo -n "."
239-
sudo wget -qNO /opt/box/etc/images/${IMAGE_NAME}.json https://hub.docker.com/v2/repositories/$DEFAULT_PROJECT/${IMAGE_NAME}/tags/?page_size=256
241+
sudo wget -qNO ${WPLIB_BOX_BASE_DIR}/etc/images/${IMAGE_NAME}.json https://hub.docker.com/v2/repositories/$DEFAULT_PROJECT/${IMAGE_NAME}/tags/?page_size=256
240242
done
241243
echo "Done"
242244
}
@@ -245,10 +247,10 @@ d_update()
245247
d_show()
246248
{
247249
echo "$ECHO_PREFIX ${GREEN}Available images on repository.${RESET}"
248-
IMAGES="`jq -r '.results|.[]|.name' /opt/box/etc/respositories.json`"
250+
IMAGES="`jq -r '.results|.[]|.name' ${WPLIB_BOX_BASE_DIR}/etc/respositories.json`"
249251
for IMAGE_NAME in $IMAGES
250252
do
251-
VERSIONS="`jq -r '.results|.[]|.name' /opt/box/etc/images/${IMAGE_NAME}.json`"
253+
VERSIONS="`jq -r '.results|.[]|.name' ${WPLIB_BOX_BASE_DIR}/etc/images/${IMAGE_NAME}.json`"
252254
for IMAGE_VERSION in $VERSIONS
253255
do
254256
echo "$DEFAULT_PROJECT/${IMAGE_NAME}:$IMAGE_VERSION"
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)