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" CONFIG_ROOT="$HOME/.config/tori"
TMP_DIR="/tmp/tori" TMP_DIR="/tmp/tori"
. "$TORI_ROOT/src/package.sh" . "$TORI_ROOT/src/index.sh"
. "$TORI_ROOT/src/utility.sh"
. "$TORI_ROOT/src/configuration.sh"
# state # state
@ -29,23 +27,11 @@ system_packages=
prepare_directories prepare_directories
if [ "$argument" = check ]; then if [ "$argument" = check ]; then
base_files="$(scan_directory "$CONFIG_ROOT/base")" check
bkp_files="$(scan_directory "$CONFIG_ROOT/bkp")" elif [ "$argument" = version ] || [ "$argument" = -v ] || [ "$argument" = --version ]; then
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
echo "$VERSION" echo "$VERSION"
elif [ "$argument" = help ] || [ "$argument" = -h ] || [ "$argument" = --help ]; then elif [ "$argument" = help ] || [ "$argument" = -h ] || [ "$argument" = --help ]; then
printf "\n\ttori: configuration managent and system replication tool\n" print_help
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"
else else
echo "Use 'tori help' for usage instructions" echo "Use 'tori help' for usage instructions"
fi fi

View file

@ -24,3 +24,12 @@ prepare_directories() {
fi 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"
}