Extract main entry point cases

This commit is contained in:
Juno Takano 2024-07-07 15:31:28 -03:00
parent a728b97fad
commit df1ffcbedf
4 changed files with 26 additions and 18 deletions

9
src/check.sh Normal file
View file

@ -0,0 +1,9 @@
check() {
base_files="$(scan_directory "$CONFIG_ROOT/base")"
bkp_files="$(scan_directory "$CONFIG_ROOT/bkp")"
log debug "collected base files:\n$base_files"
log debug "collected bkp files:\n$bkp_files"
scan_packages
}

4
src/index.sh Normal file
View file

@ -0,0 +1,4 @@
. "$TORI_ROOT/src/check.sh"
. "$TORI_ROOT/src/configuration.sh"
. "$TORI_ROOT/src/package.sh"
. "$TORI_ROOT/src/utility.sh"

View file

@ -5,9 +5,7 @@ TORI_ROOT="$HOME/tori"
CONFIG_ROOT="$HOME/.config/tori"
TMP_DIR="/tmp/tori"
. "$TORI_ROOT/src/package.sh"
. "$TORI_ROOT/src/utility.sh"
. "$TORI_ROOT/src/configuration.sh"
. "$TORI_ROOT/src/index.sh"
# state
@ -29,23 +27,11 @@ system_packages=
prepare_directories
if [ "$argument" = check ]; then
base_files="$(scan_directory "$CONFIG_ROOT/base")"
bkp_files="$(scan_directory "$CONFIG_ROOT/bkp")"
log debug "collected base files:\n$base_files"
log debug "collected bkp files:\n$bkp_files"
scan_packages
elif [ "$argument" = version ] || [ "$argument" = '-v' ] || [ "$argument" = '--version' ]; then
check
elif [ "$argument" = version ] || [ "$argument" = -v ] || [ "$argument" = --version ]; then
echo "$VERSION"
elif [ "$argument" = help ] || [ "$argument" = -h ] || [ "$argument" = --help ]; then
printf "\n\ttori: configuration managent and system replication tool\n"
printf "\n\tOptions:\n\n"
printf "\tcheck\t\tcompare configuration to system state\n"
printf "\n"
printf "\tversion\t\tprint current version with release date\n"
printf "\thelp\t\tshow this help text\n"
printf "\n\tSee 'man tori' or https://brew.bsd.cafe/jutty/tori for more\n\n"
print_help
else
echo "Use 'tori help' for usage instructions"
fi

View file

@ -24,3 +24,12 @@ prepare_directories() {
fi
}
print_help() {
printf "\n tori: configuration managent and system replication tool\n"
printf "\n Options:\n\n"
printf "\tcheck\t\tcompare configuration to system state\n"
printf "\n"
printf "\tversion\t\tprint current version with release date\n"
printf "\thelp\t\tshow this help text\n"
printf "\n See 'man tori' or https://brew.bsd.cafe/jutty/tori for more\n\n"
}