From df1ffcbedf6ad2cc27005bf32b0a31cb5f89c6ae Mon Sep 17 00:00:00 2001 From: jutty Date: Sun, 7 Jul 2024 15:31:28 -0300 Subject: [PATCH] Extract main entry point cases --- src/check.sh | 9 +++++++++ src/index.sh | 4 ++++ src/tori | 22 ++++------------------ src/utility.sh | 9 +++++++++ 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 src/check.sh create mode 100644 src/index.sh diff --git a/src/check.sh b/src/check.sh new file mode 100644 index 0000000..2421b01 --- /dev/null +++ b/src/check.sh @@ -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 +} diff --git a/src/index.sh b/src/index.sh new file mode 100644 index 0000000..dfa6083 --- /dev/null +++ b/src/index.sh @@ -0,0 +1,4 @@ +. "$TORI_ROOT/src/check.sh" +. "$TORI_ROOT/src/configuration.sh" +. "$TORI_ROOT/src/package.sh" +. "$TORI_ROOT/src/utility.sh" diff --git a/src/tori b/src/tori index e95074e..05501a7 100755 --- a/src/tori +++ b/src/tori @@ -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 diff --git a/src/utility.sh b/src/utility.sh index 92dc194..cfd0e14 100644 --- a/src/utility.sh +++ b/src/utility.sh @@ -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" +}