auto-completion for post ; readme ; install

This commit is contained in:
Cyrille L 2022-02-16 16:57:20 +01:00
parent 9878785dac
commit 470757fb89
6 changed files with 40 additions and 2 deletions

View File

@ -44,6 +44,8 @@ To avoid sudo, you should give permissions to USER
## Destination Folder: /usr/local/bin ## Destination Folder: /usr/local/bin
- File: gsl - File: gsl
## Destination Folder: /usr/share/bash-completion/completions/gsl
- File: gsl
# How to configure a DOMAIN folder, and create a Post # How to configure a DOMAIN folder, and create a Post
------------------------------------------------------------------------ ------------------------------------------------------------------------

View File

@ -132,7 +132,13 @@ case "$1" in
gsl__check_source "$gsl_dir_scripts/gsl__db_manager" || exit 1 gsl__check_source "$gsl_dir_scripts/gsl__db_manager" || exit 1
case "$2" in case "$2" in
-F) gsl_force_check=true -F)
gsl_force_check=true
[[ "$3" ]] && gsl__check_opt_post "$3"
;;
*)
[[ "$2" ]] && gsl__check_opt_post "$2"
;;
esac esac
gsl__logs_print \ gsl__logs_print \

View File

@ -0,0 +1,12 @@
_gsl_completions()
{
local gslfiles cur
gslfiles=$(ls -1 *.gsl 2>/dev/null)
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "$gslfiles" -- ${cur}) )
return 0
}
complete -F _gsl_completions gsl

View File

@ -44,6 +44,8 @@ To avoid sudo, you should give permissions to USER
## Destination Folder: /usr/local/bin ## Destination Folder: /usr/local/bin
- File: gsl - File: gsl
## Destination Folder: /usr/share/bash-completion/completions/gsl
- File: gsl
# How to configure a DOMAIN folder, and create a Post # How to configure a DOMAIN folder, and create a Post
------------------------------------------------------------------------ ------------------------------------------------------------------------

View File

@ -28,3 +28,6 @@ To avoid sudo, you should give permissions to USER
## Destination Folder: /usr/local/bin ## Destination Folder: /usr/local/bin
- File: gsl - File: gsl
## Destination Folder: /usr/share/bash-completion/completions/gsl
- File: gsl

View File

@ -4,6 +4,14 @@
# By echolib # By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#=======================================================================
# Check NAME post from [OPT] ; should be from autocompletion
#=======================================================================
gsl__check_opt_post() {
[[ `ls -1 *.gsl | grep "$1"` ]] \
&& gsl_this_post="$1"
}
#======================================================================= #=======================================================================
# Check if posts from PWD folder # Check if posts from PWD folder
#======================================================================= #=======================================================================
@ -21,6 +29,11 @@ gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l`
gsl__loop_posts() { gsl__loop_posts() {
for gsl_post in `ls -1 *.gsl 2>/dev/null` for gsl_post in `ls -1 *.gsl 2>/dev/null`
do do
# Check specific asked Post
if [[ "$gsl_this_post" ]];then
! [[ "$gsl_post" == "$gsl_this_post" ]] && continue
fi
# Post too small # Post too small
gsl__post_hash_size gsl__post_hash_size
if (( "$gsl_post_size" <= $gsl_post_min_size ));then if (( "$gsl_post_size" <= $gsl_post_min_size ));then
@ -69,7 +82,7 @@ do
done done
[[ "$gsl_check_done" ]] \ [[ "$gsl_check_done" ]] \
&& echo "# All posts already checked" && echo "# Check already done"
} }
#======================================================================= #=======================================================================