Skip to content

Commit

Permalink
changed(EFDE): #10 Disable automatic EFDE update - Available by param…
Browse files Browse the repository at this point in the history
…eter --update
  • Loading branch information
mmaximo33 committed Jan 12, 2023
1 parent 4e16d1f commit ddc5d2d
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 46 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Removed


## [Unreleased] AAAA-MM-DD
### Changed
- EFDE: #10 Disable automatic EFDE update - Available by parameter --update

## [1.1.1] 2022-12-28
### Fixed
- (Symfony): Fix createapp script sequence
Expand Down
15 changes: 0 additions & 15 deletions bin/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,6 @@ def checkEnvironment():

return menu_current


def checkUpdate():
response = codecs.decode(common.cliReturn('cd ~/.efde;git pull'),'UTF-8')
if not response == 'Already up to date.\n':
confirm = common.checkYesNo(common.msgColor('There is a new version, do you want to update EFDE?','WARNING'),'n')
if confirm: EfdeUpdate()

def EfdeUpdate():
print(common.msgColor('Updating...','INFO_CYAN'))
common.cli(f'cd ~/.efde; git checkout main;git reset --hard origin/main;git pull origin main')
exit()


def setNameProject():
while True:
projectName = input(f'Enter the project name [my-project]\nProject Name: ')
Expand Down Expand Up @@ -94,8 +81,6 @@ def moreInfo():


if __name__ == '__main__':
checkUpdate()

menu_current = menu_option_start # default menu

efdeConfigExists = checkConfigEfdeEnv()
Expand Down
118 changes: 87 additions & 31 deletions setup/efde.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
#
# EFDE : Easy and fast development environment
# Author : Marucci Maximo (https://mmaximo33.github.io/cv/)
# Created On : 2022-11-01
# Last Modified By : Marucci Maximo
# Last Modified On : 2022-11-27
# Status : construction
# GitLab : https://gitlab.com/dockerizations/efde
# GitHub : https://github.com/mmaximo33/efde
# GitLab : https://gitlab.com/dockerizations/efde
# Description :

# make sure we exit on error
set -e
# Make sure we exit on error
set -euo pipefail

# set the version and revision
# Set the version and revision
project_run="$(basename $0)"
project_name="Easy and fast development environment"
project_version='v1.1.1'
Expand All @@ -24,19 +20,29 @@ project_version='v1.1.1'
######## #########
######################################################################

questionYesNo(){
while true; do
read -p "Are you sure you want to remove EFDE? [y/n]: " yn
efde_echo() {
command printf %s\\n "$*" 2>/dev/null
}

question_yes_no() {
while true; do
read -p "$1 [y/n]: " yn
case $yn in
[Yy]* ) removeEfde; break;;
[Nn]* ) echo "Operation cancelled"; exit;;
* ) echo "You must indicate a valid option";;
[Yy]*)
$2
exit
;;
[Nn]*)
$3
exit
;;
*) efde_echo "You must indicate a valid option" ;;
esac
done

}

showHelp(){
show_help() {
cat >&2 <<END
${project_name^^} | ${project_run^^} | $project_version
Debian GNU/LINUX
Expand All @@ -49,6 +55,7 @@ Options:
-h, --help Use and arguments
-v, --version Show current version
-i, --info Official project information ${project_run^^}
--update Update ${project_run^^}
--remove Remove ${project_run^^}
By default, ${project_run^^} will determine the actions it can perform on the directory where it was executed.
Expand All @@ -59,28 +66,58 @@ END

}

showVersion(){
cat >&2 $project_version
show_version() {
efde_echo $project_version
}

openMoreInfo(){
open_more_info() {
url="https://github.com/mmaximo33/efde"
xdg-open $url
}

removeEfde(){
remove_check() {
question_yes_no "Do you want to remove EFDE from your computer?" remove_action break
}

remove_action() {
echo -e "\nOkey. We will be removing ${project_run^^} from your computer"
sleep 6s
sleep 3s
rm -rf ~/.efde
rm ~/bin/efde
echo "We remove all elements related to ${project_run^^}"
sleep 6s
echo -e "\nRemember that you can reinstall it by following these steps\n"
echo -e "We remove all elements related to ${project_run^^}"
sleep 3s
openMoreInfo
echo -e "\nRemember that you can reinstall it by following these steps\n"
sleep 2s
open_more_info
}

update_check() {
# https://stackoverflow.com/a/3278427
UPSTREAM=${1:-'@{u}'}
LOCAL=$(
cd $HOME/.efde
git rev-parse @
)
REMOTE=$(
cd $HOME/.efde
git rev-parse "$UPSTREAM"
)
if [ $LOCAL == $REMOTE ]; then
echo -e 'Up to date!' >&2
else
efde_echo 'There is an update available!'
question_yes_no "Do you want to download the new version of ${project_run^^}?" update_action break
fi
}

update_action() {
cd $HOME/.efde
git checkout main
git reset --hard origin/main
git pull origin main
}

invalidArgument(){
invalid_argument() {
echo -e "\n${project_run}: unrecognized argument '$1'" >&2
echo -e "Try '${project_run} --help' for more information. \n" >&2
exit 1
Expand All @@ -92,13 +129,32 @@ invalidArgument(){
######## #########
######################################################################

if [[ $# -gt 0 ]] ; then
if [ $# -gt 0 ]; then
case "$1" in
-h|--help) showHelp; exit 0 ;;
-v|--version) showVersion; exit 0 ;;
-i|--info) openMoreInfo; exit 0 ;;
--remove) questionYesNo; exit 0 ;;
-*) invalidArgument $1; exit 1 ;;
-h | --help)
show_help
exit 0
;;
-v | --version)
show_version
exit 0
;;
-i | --info)
open_more_info
exit 0
;;
--update)
update_check
exit 0
;;
--remove)
remove_check
exit 0
;;
-*)
invalid_argument $1
exit 1
;;
esac
fi

Expand Down

0 comments on commit ddc5d2d

Please sign in to comment.