Skip to content

Commit

Permalink
compiled dbImportProfile using go compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
fchastanet committed Aug 31, 2024
1 parent b038877 commit b2bbc60
Show file tree
Hide file tree
Showing 52 changed files with 2,243 additions and 2,334 deletions.
2 changes: 1 addition & 1 deletion .framework-config
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ FRAMEWORK_FUNCTIONS_IGNORE_REGEXP="${FRAMEWORK_FUNCTIONS_IGNORE_REGEXP:-^(Namesp
# describe the files that do not contain function to be imported
NON_FRAMEWORK_FILES_REGEXP="${NON_FRAMEWORK_FILES_REGEXP:-(^bin/|\.framework-config|^test\.sh$|^\.github/preCommitGeneration\.sh$|^install$|\.bats$|/testsData/|^manualTests/|/_\.sh$|/ZZZ\.sh$|/__all\.sh$|^src/_binaries|^src/_includes|^src/batsHeaders\.sh$|^conf/)}"
# describe the files that are allowed to not have an associated bats file
BATS_FILE_NOT_NEEDED_REGEXP="${BATS_FILE_NOT_NEEDED_REGEXP:-(^conf/|^bin/|^\.github/preCommitGeneration\.sh$|.framework-config|^install$|\.bats$|/testsData/|^manualTests/|/_\.sh$|/ZZZ\.sh$|/__all\.sh$|^src/batsHeaders\.sh$|^src/_includes)}"
BATS_FILE_NOT_NEEDED_REGEXP="${BATS_FILE_NOT_NEEDED_REGEXP:-(^conf/|^bin/|^\.github/preCommitGeneration\.sh$|.framework-config|^install$|\.bats$|/testsData/|^manualTests/|/_\.sh$|/ZZZ\.sh$|/__all\.sh$|^src/batsHeaders\.sh$|^src/_includes|^src/_binaries/.*-(options|main)\.sh$|^conf/|^src/_binaries/commandDefinitions/options.*\.sh$|/testsData/|^test\.sh$)}"
# describe the files that are allowed to not have a function matching the filename
FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP="${FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP:-^conf/|^bin/|^\.framework-config$|\.tpl$|testsData/binaryFile$}"
# Source directories
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config-github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ repos:
exclude: /testsData/

- repo: https://github.com/fchastanet/bash-tools-framework
rev: 5.0.0
rev: 5.1.0
hooks:
- id: fixShebangExecutionBit
- id: awkLint
Expand All @@ -171,7 +171,7 @@ repos:
args:
[
--expected-warnings-count,
"6",
"4",
--format,
plain,
--theme,
Expand Down Expand Up @@ -205,6 +205,6 @@ repos:
stages: [manual] # GITHUB

- repo: https://github.com/fchastanet/bash-compiler
rev: 0.3.0
rev: 0.3.1
hooks:
- id: buildBashBinaries
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ repos:
exclude: /testsData/

- repo: https://github.com/fchastanet/bash-tools-framework
rev: 5.0.0
rev: 5.1.0
hooks:
- id: fixShebangExecutionBit
- id: awkLint
Expand All @@ -166,7 +166,7 @@ repos:
args:
[
--expected-warnings-count,
"6",
"4",
--format,
plain,
--theme,
Expand Down Expand Up @@ -200,6 +200,6 @@ repos:
stages: [] # GITHUB

- repo: https://github.com/fchastanet/bash-compiler
rev: 0.3.0
rev: 0.3.1
hooks:
- id: buildBashBinaries
23 changes: 15 additions & 8 deletions Commands.tmpl.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# The commands

- [1. Build tools](#1-build-tools)
- [1.1. bin/installRequirements](#11-bininstallrequirements)
- [1.2. bin/waitForIt](#12-binwaitforit)
- [1.3. bin/waitForMysql](#13-binwaitformysql)
- [1.4. bin/doc](#14-bindoc)
- [1.1. bin/install](#11-bininstall)
- [1.2. bin/installRequirements](#12-bininstallrequirements)
- [1.3. bin/waitForIt](#13-binwaitforit)
- [1.4. bin/waitForMysql](#14-binwaitformysql)
- [1.5. bin/doc](#15-bindoc)
- [2. Converter and Generator tools](#2-converter-and-generator-tools)
- [2.1. bin/mysql2puml](#21-binmysql2puml)
- [2.1.1. Help](#211-help)
Expand Down Expand Up @@ -36,25 +37,31 @@

## 1. Build tools

### 1.1. bin/installRequirements
### 1.1. bin/install

```text
@@@install_help@@@
```

### 1.2. bin/installRequirements

```text
@@@installRequirements_help@@@
```

### 1.2. bin/waitForIt
### 1.3. bin/waitForIt

```text
@@@waitForIt_help@@@
```

### 1.3. bin/waitForMysql
### 1.4. bin/waitForMysql

```text
@@@waitForMysql_help@@@
```

### 1.4. bin/doc
### 1.5. bin/doc

```text
@@@doc_help@@@
Expand Down
47 changes: 28 additions & 19 deletions bin/dbImport
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,13 @@ declare versionNumber="2.0"
declare optionBashFrameworkConfig="${BASH_TOOLS_ROOT_DIR}/.framework-config"
declare defaultTargetCharacterSet=""

declare TIMEFORMAT='time spent : %3R'
declare DOWNLOAD_DUMP=0

declare DB_IMPORT_DUMP_DIR
declare PROFILES_DIR
declare HOME_PROFILES_DIR

beforeParseCallback() {
BashTools::Conf::requireLoad
Env::requireLoad
Expand All @@ -1695,6 +1702,13 @@ beforeParseCallback() {
Linux::requireExecutedAsUser
}

initConf() {
# shellcheck disable=SC2034
DB_IMPORT_DUMP_DIR=${DB_IMPORT_DUMP_DIR%/}
PROFILES_DIR="${BASH_TOOLS_ROOT_DIR}/conf/dbImportProfiles"
HOME_PROFILES_DIR="${HOME}/.bash-tools/dbImportProfiles"
}

optionHelpCallback() {
dbImportCommandHelp
exit 0
Expand Down Expand Up @@ -2431,7 +2445,7 @@ dbImportCommandParse() {
elif (( options_parse_parsedArgIndex >= minParsedArgIndex0 &&
options_parse_parsedArgIndex < maxParsedArgIndex1 )); then
if ((options_parse_argParsedCountFromDbName >= 1 )); then
Log::displayError "Command ${SCRIPT_NAME} - Argument <fromDbName> - Maximum number of argument occurrences reached(1)"
Log::displayError "Command ${SCRIPT_NAME} - Argument fromDbName - Maximum number of argument occurrences reached(1)"
return 1
fi
((++options_parse_argParsedCountFromDbName))
Expand Down Expand Up @@ -2494,7 +2508,7 @@ dbImportCommandParse() {


if ((options_parse_argParsedCountFromDbName < 1 )); then
Log::displayError "Command ${SCRIPT_NAME} - Argument '<fromDbName>' should be provided at least 1 time(s)"
Log::displayError "Command ${SCRIPT_NAME} - Argument 'fromDbName' should be provided at least 1 time(s)"
return 1
fi || return $?

Expand All @@ -2521,7 +2535,7 @@ dbImportCommandHelp() {
# ------------------------------------------
# usage/options section
# ------------------------------------------
optionsAltList=("[--collation-name|-o <<targetDsn>>]" "[--target-dsn|-t <<targetDsn>>]" "[--character-set|-c <<targetDsn>>]" "[--profile|-p <<dsn>>]" "[--tables <<tablesSeparatedByComma>>]" "[--skip-schema|-s]" "[--from-dsn|-f <<dsn>>]" "[--from-aws|-a <<awsFile>>]" "[--help|-h]" "[--config]" "[--bash-framework-config <bash-framework-config>]" "[--verbose|-v]" "[-vv]" "[-vvv]" "[--env-file <env-file>]" "[--log-level <log-level>]" "[--log-file <log-file>]" "[--display-level <display-level>]" "[--no-color]" "[--theme <theme>]" "[--version]" "[--quiet|-q]"
optionsAltList=("[--collation-name|-o <targetDsn>]" "[--target-dsn|-t <targetDsn>]" "[--character-set|-c <characterSet>]" "[--profile|-p <profile>]" "[--tables <tablesSeparatedByComma>]" "[--skip-schema|-s]" "[--from-dsn|-f <dsn>]" "[--from-aws|-a <awsFile>]" "[--help|-h]" "[--config]" "[--bash-framework-config <bash-framework-config>]" "[--verbose|-v]" "[-vv]" "[-vvv]" "[--env-file <env-file>]" "[--log-level <log-level>]" "[--log-file <log-file>]" "[--display-level <display-level>]" "[--no-color]" "[--theme <theme>]" "[--version]" "[--quiet|-q]"
)
Array::wrap2 " " 80 2 "${__HELP_TITLE_COLOR}USAGE:${__RESET_COLOR}" \
"dbImport" "${optionsAltList[@]}"
Expand All @@ -2533,11 +2547,11 @@ dbImportCommandHelp() {
echo
echo -e "${__HELP_TITLE_COLOR}ARGUMENTS:${__RESET_COLOR}"

Array::wrap2 " " 80 2 " ${__HELP_OPTION_COLOR}<fromDbName>${__HELP_NORMAL}{single} (mandatory)
Array::wrap2 " " 80 2 " ${__HELP_OPTION_COLOR}fromDbName${__HELP_NORMAL} {single} (mandatory)
"
Array::wrap2 ' ' 76 4 " " "The name of the source/remote database."
echo
Array::wrap2 " " 80 2 " [${__HELP_OPTION_COLOR}<targetDbName>${__HELP_NORMAL}{single}]
Array::wrap2 " " 80 2 " [${__HELP_OPTION_COLOR}<targetDbName>${__HELP_NORMAL} {single}]
"
Array::wrap2 ' ' 76 4 " " "The name of the target database" "Default value: <fromDbName>(without extension)" ""
echo
Expand All @@ -2560,14 +2574,14 @@ dbImportCommandHelp() {
Array::wrap2 ' ' 76 6 " Default value: " "default.local"
echo

echo -e " ${__HELP_OPTION_COLOR}--character-set${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}-c <targetDsn>${__HELP_NORMAL} {single}"
echo -e " ${__HELP_OPTION_COLOR}--character-set${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}-c <characterSet>${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Change the character set used during database creation."
echo


echo
echo -e "${__HELP_TITLE_COLOR}PROFILE OPTIONS:${__RESET_COLOR}"
echo -e " ${__HELP_OPTION_COLOR}--profile${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}-p <dsn>${__HELP_NORMAL} {single}"
echo -e " ${__HELP_OPTION_COLOR}--profile${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}-p <profile>${__HELP_NORMAL} {single}"
profileOptionHelpFunction


Expand Down Expand Up @@ -2613,7 +2627,7 @@ dbImportCommandHelp() {



echo -e " ${__HELP_OPTION_COLOR}--bash-framework-config bash-framework-config${__HELP_NORMAL} {single}"
echo -e " ${__HELP_OPTION_COLOR}--bash-framework-config <bash-framework-config>${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Use alternate bash framework configuration."
echo

Expand All @@ -2637,26 +2651,26 @@ dbImportCommandHelp() {



echo -e " ${__HELP_OPTION_COLOR}--env-file env-file${__HELP_NORMAL} {list} (optional)"
echo -e " ${__HELP_OPTION_COLOR}--env-file <env-file>${__HELP_NORMAL} {list} (optional)"
Array::wrap2 ' ' 76 4 " " "Load the specified env file (deprecated, please use --bash-framework-config option instead)"
echo



echo -e " ${__HELP_OPTION_COLOR}--log-level log-level${__HELP_NORMAL} {single}"
echo -e " ${__HELP_OPTION_COLOR}--log-level <log-level>${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Set log level"
echo
Array::wrap2 ' ' 76 6 " Possible values: " "OFF, " "ERR, " "ERROR, " "WARN, " "WARNING, " "INFO, " "DEBUG, " "TRACE"
echo


echo -e " ${__HELP_OPTION_COLOR}--log-file log-file${__HELP_NORMAL} {single}"
echo -e " ${__HELP_OPTION_COLOR}--log-file <log-file>${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Set log file"
echo



echo -e " ${__HELP_OPTION_COLOR}--display-level display-level${__HELP_NORMAL} {single}"
echo -e " ${__HELP_OPTION_COLOR}--display-level <display-level>${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Set display level"
echo
Array::wrap2 ' ' 76 6 " Possible values: " "OFF, " "ERR, " "ERROR, " "WARN, " "WARNING, " "INFO, " "DEBUG, " "TRACE"
Expand All @@ -2669,7 +2683,7 @@ dbImportCommandHelp() {



echo -e " ${__HELP_OPTION_COLOR}--theme theme${__HELP_NORMAL} {single}"
echo -e " ${__HELP_OPTION_COLOR}--theme <theme>${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Choose color theme - default-force means colors will be produced even if command is piped."
echo
Array::wrap2 ' ' 76 6 " Possible values: " "default, " "default-force, " "noColor"
Expand Down Expand Up @@ -2721,6 +2735,7 @@ dbImportCommandHelp() {


beforeParseCallback
initConf

dbImportCommandParse "$@"
MAIN_FUNCTION_NAME="main"
Expand All @@ -2735,12 +2750,6 @@ Compiler::Embed::extractFileFromBase64 \
declare -gx embed_file_dumpSizeQuery="${PERSISTENT_TMPDIR:-/tmp}/95e2e89e049fcfcd74a8b75390f067bf/dumpSizeQuery"


declare TIMEFORMAT='time spent : %3R'
declare DB_IMPORT_DUMP_DIR=${DB_IMPORT_DUMP_DIR%/}
declare PROFILES_DIR="${BASH_TOOLS_ROOT_DIR}/conf/dbImportProfiles"
declare HOME_PROFILES_DIR="${HOME}/.bash-tools/dbImportProfiles"
declare DOWNLOAD_DUMP=0

# dump header/footer
read -r -d '\0' DUMP_HEADER <<-EOM
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0;
Expand Down
Loading

0 comments on commit b2bbc60

Please sign in to comment.