From 470757fb899095ce1244f68ec39ec963802d6618 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Wed, 16 Feb 2022 16:57:20 +0100 Subject: [PATCH] auto-completion for post ; readme ; install --- README.md | 2 ++ usr/local/bin/gsl | 8 +++++++- usr/share/bash-completion/completions/gsl | 12 ++++++++++++ var/lib/gsl/README.md | 2 ++ var/lib/gsl/helps/gsl_help_install | 3 +++ var/lib/gsl/scripts/gsl__post_manager | 15 ++++++++++++++- 6 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 usr/share/bash-completion/completions/gsl diff --git a/README.md b/README.md index 288a497..7b1c799 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ To avoid sudo, you should give permissions to USER ## Destination Folder: /usr/local/bin - File: gsl +## Destination Folder: /usr/share/bash-completion/completions/gsl +- File: gsl # How to configure a DOMAIN folder, and create a Post ------------------------------------------------------------------------ diff --git a/usr/local/bin/gsl b/usr/local/bin/gsl index 59d7018..6edb29d 100755 --- a/usr/local/bin/gsl +++ b/usr/local/bin/gsl @@ -132,7 +132,13 @@ case "$1" in gsl__check_source "$gsl_dir_scripts/gsl__db_manager" || exit 1 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 gsl__logs_print \ diff --git a/usr/share/bash-completion/completions/gsl b/usr/share/bash-completion/completions/gsl new file mode 100644 index 0000000..c858307 --- /dev/null +++ b/usr/share/bash-completion/completions/gsl @@ -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 diff --git a/var/lib/gsl/README.md b/var/lib/gsl/README.md index 288a497..7b1c799 100644 --- a/var/lib/gsl/README.md +++ b/var/lib/gsl/README.md @@ -44,6 +44,8 @@ To avoid sudo, you should give permissions to USER ## Destination Folder: /usr/local/bin - File: gsl +## Destination Folder: /usr/share/bash-completion/completions/gsl +- File: gsl # How to configure a DOMAIN folder, and create a Post ------------------------------------------------------------------------ diff --git a/var/lib/gsl/helps/gsl_help_install b/var/lib/gsl/helps/gsl_help_install index 6d65b20..73ac72e 100644 --- a/var/lib/gsl/helps/gsl_help_install +++ b/var/lib/gsl/helps/gsl_help_install @@ -28,3 +28,6 @@ To avoid sudo, you should give permissions to USER ## Destination Folder: /usr/local/bin - File: gsl +## Destination Folder: /usr/share/bash-completion/completions/gsl +- File: gsl + diff --git a/var/lib/gsl/scripts/gsl__post_manager b/var/lib/gsl/scripts/gsl__post_manager index 2047885..cc66fa1 100644 --- a/var/lib/gsl/scripts/gsl__post_manager +++ b/var/lib/gsl/scripts/gsl__post_manager @@ -4,6 +4,14 @@ # By echolib # 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 #======================================================================= @@ -21,6 +29,11 @@ gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l` gsl__loop_posts() { for gsl_post in `ls -1 *.gsl 2>/dev/null` do + # Check specific asked Post + if [[ "$gsl_this_post" ]];then + ! [[ "$gsl_post" == "$gsl_this_post" ]] && continue + fi + # Post too small gsl__post_hash_size if (( "$gsl_post_size" <= $gsl_post_min_size ));then @@ -69,7 +82,7 @@ do done [[ "$gsl_check_done" ]] \ - && echo "# All posts already checked" + && echo "# Check already done" } #=======================================================================