add import and export

This commit is contained in:
abrown38 committed 2026-09-29 16:40:56 +00:00
1 parent d4bd93bbe1
commit 35f541458c
7 files changed
+369 -38

No files matched your search

+22 -7
View File
@@ -46,6 +46,20 @@ _terractl_mods() {
fi
}
# File names, optionally only those ending in .<extension> (folders always offered)
_terractl_files() {
if declare -F _filedir >/dev/null 2>&1; then
_filedir "$@"
else
compopt -o filenames 2>/dev/null
if [[ -n ${1:-} ]]; then
mapfile -t COMPREPLY < <(compgen -d -- "$cur"; compgen -f -X "!*.$1" -- "$cur")
else
mapfile -t COMPREPLY < <(compgen -f -- "$cur")
fi
fi
}
# Set COMPREPLY to the words matching what's typed so far
_terractl_reply() {
mapfile -t COMPREPLY < <(compgen -W "$1" -- "$cur")
@@ -63,7 +77,7 @@ _terractl() {
cword=$COMP_CWORD
fi
local commands="new list attach cmd mods reinstall delete prepare run --help --version"
local commands="new list attach cmd mods reinstall delete export import prepare run --help --version"
local console="save say playing kick ban motd password time dawn noon dusk midnight settle seed version maxplayers port clear help"
if (( cword == 1 )); then
@@ -79,6 +93,10 @@ _terractl() {
# new <new name> [vanilla|tmodloader] [port]: the name is new, so nothing to offer
if (( cword == 3 )); then _terractl_reply "vanilla tmodloader"; fi
return ;;
import)
# import <new name> <file.tar.gz>: the name is new, so nothing to offer
if (( cword == 3 )); then _terractl_files tar.gz; fi
return ;;
esac
if (( cword == 2 )); then
@@ -94,6 +112,8 @@ _terractl() {
if (( cword == 3 )); then _terractl_reply "--clean"; fi ;;
delete)
_terractl_reply "-y --yes --no-backup" ;;
export)
if [[ $cur == -* ]]; then _terractl_reply "--with-server"; else _terractl_files tar.gz; fi ;;
mods)
if (( cword == 3 )); then
_terractl_reply "list add enable disable remove"
@@ -102,12 +122,7 @@ _terractl() {
case ${words[3]} in
add)
# .tmod files and folders (e.g. the Windows export folder)
if declare -F _filedir >/dev/null 2>&1; then
_filedir tmod
else
compopt -o filenames 2>/dev/null
mapfile -t COMPREPLY < <(compgen -d -- "$cur"; compgen -f -X '!*.tmod' -- "$cur")
fi ;;
_terractl_files tmod ;;
enable|remove)
_terractl_reply "$(_terractl_mods "$instance" installed)" ;;
disable)