feature: add descriptions to each command and cleanup usage message.
This commit is contained in:
80
mc
80
mc
@@ -13,39 +13,39 @@ readonly headers=( -H "Accept: application/json" -H "Content-Type: application/j
|
||||
# command format: '<endpoint> <method> [options]'
|
||||
|
||||
declare -rA commands=(
|
||||
[hello]='hello GET'
|
||||
[time]='time GET'
|
||||
[stats]='stats GET'
|
||||
[log]='log GET'
|
||||
[start]='start GET'
|
||||
[stop]='stop GET'
|
||||
[restart]='restart GET'
|
||||
[my-link]='my-link GET'
|
||||
[my-geyser-link]='my-geyser-link GET'
|
||||
[my-sftp]='my-sftp GET'
|
||||
[my-hash]='my-hash GET'
|
||||
[my-geyser-hash]='my-geyser-hash GET'
|
||||
[my-hash-sftp]='my-hash-sftp GET'
|
||||
[list-players]='list-players GET'
|
||||
[website]='website GET'
|
||||
[map]='map GET'
|
||||
[status-minecraft]='status/Minecraft GET'
|
||||
[status-bedrock]='status/Bedrock GET'
|
||||
[status-sftp]='status/SFTP GET'
|
||||
[ban]='ban POST {"username":"%s"}'
|
||||
[unban]='unban POST {"username":"%s"}'
|
||||
[say]='say POST {"message":"%s"}'
|
||||
[tell]='tell POST {"username":"%s","message":"%s"}'
|
||||
[console]='console POST {"command":"%s"}'
|
||||
[give]='give POST {"username":"%s","item":"%s","amount":"%s"}'
|
||||
[install]='install POST {"mod":"%s"}'
|
||||
[uninstall]='uninstall POST {"mod":"%s"}'
|
||||
[search]='search POST {"mod":"%s"}'
|
||||
[mod-list]='mod-list GET'
|
||||
[backup]='backup FUNC'
|
||||
[connect]='connect FUNC'
|
||||
[check-update]='check_update FUNC game_version'
|
||||
[version]='version FUNC'
|
||||
[hello]='hello GET {} Say hello to the server.'
|
||||
[time]='time GET {} Get server time.'
|
||||
[stats]='stats GET {} Get stats of server container.'
|
||||
[log]='log GET {} Get link for server logs.'
|
||||
[start]='start GET {} Start the server.'
|
||||
[stop]='stop GET {} Stop the server.'
|
||||
[restart]='restart GET {} Restart the server.'
|
||||
[my-link]='my-link GET {} Get connection info for server.'
|
||||
[my-geyser-link]='my-geyser-link GET {} Get info for Bedrock connection.'
|
||||
[my-sftp]='my-sftp GET {} Get connection info for sftp connection.'
|
||||
[my-hash]='my-hash GET {} Get Holsail connection info.'
|
||||
[my-geyser-hash]='my-geyser-hash GET {} Get Holesail connection information for bedrock connection.'
|
||||
[my-hash-sftp]='my-hash-sftp GET {} Get the Holesail connection information.'
|
||||
[list-players]='list-players GET {} List players on the server.'
|
||||
[website]='website GET {} Get link to Website.'
|
||||
[map]='map GET {} Get link to Bluemap.'
|
||||
[status-minecraft]='status/Minecraft GET {} Get status of the my-link connection to the server.'
|
||||
[status-bedrock]='status/Bedrock GET {} Get status of the bedrock connection to the server.'
|
||||
[status-sftp]='status/SFTP GET {} Get status and info of sftp connection to the server.'
|
||||
[ban]='ban POST {"username":"%s"} Ban a player.'
|
||||
[unban]='unban POST {"username":"%s"} Unban a player.'
|
||||
[say]='say POST {"message":"%s"} Broadcast a message on the server.'
|
||||
[tell]='tell POST {"username":"%s","message":"%s"} Send a message to a player.'
|
||||
[console]='console POST {"command":"%s"} Run a console command.'
|
||||
[give]='give POST {"username":"%s","item":"%s","amount":"%s"} Give player item.'
|
||||
[install]='install POST {"mod":"%s"} install a mod using id.'
|
||||
[uninstall]='uninstall POST {"mod":"%s"} Uninstall a mod using id.'
|
||||
[search]='search POST {"mod":"%s"} Search for mods by name or id.'
|
||||
[mod-list]='mod-list GET {} Get list of mods installed on ther server.'
|
||||
[backup]='backup FUNC {} EXPERIMENTAL! Make a local copy of server files over sftp.'
|
||||
[connect]='connect FUNC {} Open a connection to server using docker-holesail on port 25565.'
|
||||
[check-update]='check_update FUNC {game_version} Check installed mods have available version.'
|
||||
[version]='version FUNC {} Check the version of Minecraft the server is running.'
|
||||
)
|
||||
|
||||
function version() {
|
||||
@@ -124,16 +124,16 @@ function usage() {
|
||||
printf "API key for my-mc must be exported using 'export MY_MC_API_KEY=<my-mc api key>'\n\n"
|
||||
printf "Backup directory can be changed from default ~/mc-mc_backup/ by using 'export MY_MC_BACKUP_DIR=</path/to/dir/>'\n\n"
|
||||
printf "Positional arguments will fill the JSON objects with values from left to right.\n\n"
|
||||
printf "COMMANDS:\n"
|
||||
|
||||
local -a message=("COMMAND\tARGUMENTS\tDESCRIPTION\n")
|
||||
local command
|
||||
for command in "${!commands[@]}"; do
|
||||
local endpoint method body
|
||||
read -r endpoint method body <<<"${commands[${command}]}"
|
||||
echo -e "\t ${command} ${body}" | sed 's/[":\{\}]//g' |sed 's/%s//g'| sed 's/[,]/ /g'
|
||||
local endpoint method body description
|
||||
read -r endpoint method body description <<<"${commands[${command}]}"
|
||||
message+=("$(echo -e "${command}\t${body}" | sed 's/[":\{\}]//g' |sed 's/%s//g'| sed 's/[,]/ /g')\t$description\n")
|
||||
done
|
||||
|
||||
printf "\n"
|
||||
echo -e "${message[*]}" | column -t -s $'\t'
|
||||
}
|
||||
|
||||
|
||||
@@ -151,8 +151,8 @@ function main() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local endpoint method body
|
||||
read -r endpoint method body <<<"${commands[$1]}"
|
||||
local endpoint method body description
|
||||
read -r endpoint method body description <<<"${commands[$1]}"
|
||||
|
||||
case "${method}" in
|
||||
"POST")
|
||||
|
Reference in New Issue
Block a user