From c07e3ff37d5d907e87e26a22706dece25d4dd288 Mon Sep 17 00:00:00 2001 From: ilguappo Date: Fri, 18 Jul 2025 08:26:49 -0700 Subject: [PATCH] feature: add connect command --- mc | 16 +++++++++++++++- mc-test.sh | 18 ++++++++---------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/mc b/mc index beae55d..d82e659 100755 --- a/mc +++ b/mc @@ -38,8 +38,21 @@ declare -rA commands=( [search]='search POST {"mod":"%s"}' [mod-list]='mod-list GET' [backup]='backup FUNC' + [connect]='connect FUNC' ) +function connect() { + if [[ ! $(which docker) ]]; then echo "docker is required"; exit 1; fi + docker run --rm \ + -e MODE=my-mc \ + -e PORT=25565 \ + -e HOST=0.0.0.0 \ + -e PUBLIC=false \ + -e MY_MC_API_KEY=$MY_MC_API_KEY \ + -p 25565:25565 anaxios/holesail:testing + echo "" +} + function backup() { if [[ ! $(which lftp) ]]; then echo "lftp is required"; exit 1; fi @@ -59,7 +72,8 @@ function backup() { pushd "${localdir}" - lftp -u "${username}","${password}" "${host}":"${port}" -e "set sftp:connect-program 'ssh -o StrictHostKeyChecking=no'; mirror -c --use-pget minecraft/ minecraft/; quit" + lftp -u "${username}","${password}" "${host}":"${port}" \ + -e "set sftp:connect-program 'ssh -o StrictHostKeyChecking=no'; mirror -c --use-pget minecraft/ minecraft/; quit" popd } diff --git a/mc-test.sh b/mc-test.sh index 5f911ba..0ace282 100644 --- a/mc-test.sh +++ b/mc-test.sh @@ -13,6 +13,12 @@ function assert() { return 1 } +function test_assert() { + local string="one two three four" + assert "$(rest ${string})" "$(rest ${string})" +} +test_assert + function first_func_returns_first_item() { local string="one two three four" assert "$(first ${string})" "one" @@ -38,15 +44,7 @@ function rest_func_returns_rest_items_from_array() { rest_func_returns_rest_items_from_array function rest_func_returns_rest_items_from_array_w_spaces() { - local a=(two "three four") - local b=("three four") - assert "$(rest "${a[@]}")" "three four" + local a=(one two "three four") + assert "$(rest ${a[@]})" "two three four" } rest_func_returns_rest_items_from_array_w_spaces - -function rest_func_returns_rest_items_from_array_item_w_spaces_removed() { - local a=("two three" four) - assert "$(rest "${a[@]}")" "four" -} -rest_func_returns_rest_items_from_array_item_w_spaces_removed -