Skip to content

Commit

Permalink
FEAT: 4 updates (configs, source, private). See PR
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalandy committed May 17, 2022
1 parent 169ee5b commit 8afa3ec
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 56 deletions.
21 changes: 13 additions & 8 deletions .bashlava_env.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash

# .bashlava_env.sh, required by bashlava
# `.bashlava_env.sh`, required by bashlava

### DO NOT update vars directly within .bashlava_env.sh
### Yo must create a new file: .bashlava_env_override.sh
### Override these env_var from .bashlava_env_override.sh
### DO NOT update vars directly within `.bashlava_env.sh`
### DO NOT duplicate `.bashlava_env.sh` under your project
### Within your projects, create this config file: `.bashlava_env_override.sh`
CFG_OVERRIDE_WITH_CUSTOM_CONFIG="true"
CFG_CUSTOM_CONFIG_FILE_NAME=".bashlava_env_override.sh"

### .bashlava_env_override.sh
### Set these env vars via `.bashlava_env_override.sh`
# APP_NAME="notset"
# GITHUB_USER="notset"
# APP_VERSION="0.0.1"
Expand All @@ -19,9 +19,14 @@ CFG_DEFAULT_DEV_BRANCH="edge"
CFG_USER_IS="${USER}"

### FUNCTION OPTIONS
CFG_EDGE_EXTENTED="false" # #edge() not programmed yet.
CFG_LOG_LINE_NBR_SHORT="4" # log() default line number.
CFG_LOG_LINE_NBR_LONG="12" # log() default line number.
CFG_EDGE_EXTENTED="false" # #edge() not programmed yet
CFG_LOG_LINE_NBR_SHORT="4" # log() default line number
CFG_LOG_LINE_NBR_LONG="12" # log() default line number
CFG_RELEASE_POPUP="false" # TODO
CFG_HELP_ALT="false" # TODO

CFG_DEBUG_MODE="false"
CFG_LOCK_INIT="false"

### SOURCE /components
#CFG_ARR_COMPONENTS_SCRIPTS
Expand Down
1 change: 1 addition & 0 deletions .bashlava_env_override.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
APP_NAME="bashlava"
GITHUB_USER="firepress-org"
APP_VERSION="1.44.0"

80 changes: 32 additions & 48 deletions bashlava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

: '
// START COMMENT BLOCK
To-Do comment section. Total of 7
To-Do comment section. Total of 4
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
PINNED issues on GH _
Expand All @@ -22,46 +22,14 @@ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
PRIORITY 1 ____________________________________________________________________________
_______________________________________________________________________________________
TODO
Feat UX: Use config files and logic overrides
## Requirement:
- Decouple logic using files: .bashlava_env.sh and .bashlava_env_override.sh
- At the moment, its too complex for a new user to configure bashlava
- Let avoid having multiple place to define them, source components, source .md
- Few array that are configs. They should be all together under the same block of code.
## Functional impacts:
- Dockerfile file is not the place to store config anymore (old logic from https://github.com/firepress-org/ghostfire)
- Logic for .bashlava_env_override.sh, needed for this env var
APP_NAME="notset"
GITHUB_USER="notset"
APP_VERSION="0.0.1"
- Update Show_Version()
- Update Show_Tag()
- Update Show_Release()
- remove remove v_and_t()
- remove Core_Load_Vars_General()
- remove Core_Load_Vars_Dockerfile()
- remove Core_Check_Which_File_Exist()
- File: to check VERSUS file to source
- Extended Test: Show all var and config (debug)
- Think about private scripts trigger
- README docs are still missing, but its ok at this point
- Impact on: #4, #8, #10
TODO private scripts
logical flags to manage under /private/*
Need to check if files exist /private/* when DIR private exist
Need logic to manage file under /private/* fct VERSUS public fct
overide like:
- favorite URL
- custom_fct_opensite="true" # during pr, merg
- custom_fct_help="false"
- set a new config flag: debug="true"
PR Title: FEAT: 4 updates (configs, source, private). See PR
- Add new config / CFG_RELEASE_POPUP
- Add new config / CFG_LOCK_INIT
- Source .bashlava_env.sh directly from bashlava projet (not from pwd)
- Logic for private scripts is already well managed
- Impact on: #4
TODO
## App if app are installed
Expand Down Expand Up @@ -437,7 +405,9 @@ function release { # User_
sleep 0.3
Show_Version && sleep 0.3
Show_Tag && sleep 0.3

Show_Release
# CFG_RELEASE_POPUP / add logic 0o0o

Show_What_Was_Done
_doc_name="next_move_fct_release.md" && Show_Docs
Expand Down Expand Up @@ -586,6 +556,7 @@ function help { # User_
Condition_Attr_3_Must_Be_Empty
_from_fct="h"

# CFG_HELP_ALT / Add logic 0o0o
clear
_doc_name="help.md" && Show_Docs
}
Expand Down Expand Up @@ -1114,15 +1085,16 @@ function main() {
_path_docs="${_path_bashlava}/docs" _var_name="_path_docs" _is_it_empty="${_path_docs}" && Condition_Vars_Must_Be_Not_Empty

### Load default configurations
_file_is=".bashlava_env.sh" _file_path_is="$(pwd)/${_file_is}" && Condition_File_Must_Be_Present
_file_is=".bashlava_env.sh" _file_path_is="${_path_bashlava}/${_file_is}" && Condition_File_Must_Be_Present
source "${_file_path_is}"

### Load custom configurations
if [[ "${CFG_OVERRIDE_WITH_CUSTOM_CONFIG}" == "true" ]]; then
_file_is="${CFG_CUSTOM_CONFIG_FILE_NAME}" _file_path_is="$(pwd)/${CFG_CUSTOM_CONFIG_FILE_NAME}" && Condition_File_Must_Be_Present
source "${_file_path_is}"
elif [[ "${CFG_OVERRIDE_WITH_CUSTOM_CONFIG}" == "false" ]]; then
my_message="Config file is missing or not well configured: '${CFG_CUSTOM_CONFIG_FILE_NAME}'. See docs." && Print_Warning_Stop
my_message="Config file is missing or not well configured: '${CFG_CUSTOM_CONFIG_FILE_NAME}" && Print_Warning
my_message="See README for installation details." && Print_Warning_Stop
else
my_message="FATAL: Config is broken regarding: 'CFG_OVERRIDE_WITH_CUSTOM_CONFIG'." && Print_Fatal
fi
Expand All @@ -1145,7 +1117,7 @@ function main() {
### Load COMPONENTS (PUBLIC)
for action in "${CFG_ARR_COMPONENTS_SCRIPTS[@]}"; do
_file_is="${action}" _file_path_is="${_path_components}/${_file_is}" && Condition_File_Must_Be_Present
# code optimization 0o0o, add logic: _to_source="true"
# code optimization, add logic: _to_source="true" 0o0o
source "${_file_path_is}"
done

Expand All @@ -1155,8 +1127,8 @@ function main() {
if [[ -f "${_file_path_is}" ]]; then
source "${_file_path_is}"
elif [[ ! -f "${_file_path_is}" ]]; then
my_message="Warning: You should set ${_file_path_is}" && Print_Warning
my_message="See README for installation details." && Print_Warning && sleep 2
my_message="Warning: You should set ${_file_path_is} for your own scripts." && Print_Warning
my_message="See README for installation details." && Print_Warning && sleep 2
else
my_message="FATAL: Condition_File_Must_Be_Present | ${_file_path_is}" && Print_Fatal
fi
Expand Down Expand Up @@ -1194,14 +1166,26 @@ function main() {
cron_init
colour_init

### Ensure there are no more than three attrbutes
### Ensure there are no more than three attributes
Condition_Attr_4_Must_Be_Empty

### optional
# lock_init system
### Acquire script lock
if [[ "${CFG_LOCK_INIT}" == "true" ]]; then
lock_init system
elif [[ "${CFG_LOCK_INIT}" == "false" ]]; then
echo "bypassed, ok" > /dev/null
else
my_message="FATAL: Config is broken regarding: 'CFG_LOCK_INIT'." && Print_Fatal
fi

### optionnal Trace the execution of the script to debug (if needed)
# set -o xtrace
if [[ "${CFG_DEBUG_MODE}" == "true" ]]; then
set -o xtrace
elif [[ "${CFG_DEBUG_MODE}" == "false" ]]; then
echo "bypassed, ok" > /dev/null
else
my_message="FATAL: Config is broken regarding: 'CFG_DEBUG_MODE'." && Print_Fatal
fi

###'command not found' / Add logic to confirm the fct exist or not
#clear
Expand Down

0 comments on commit 8afa3ec

Please sign in to comment.