[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master afadccf 52/62: Auto-completion: Call ..._last_
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master afadccf 52/62: Auto-completion: Call ..._last_table where needed |
Date: |
Thu, 13 May 2021 22:20:54 -0400 (EDT) |
branch: master
commit afadccfc8210833d3e646c119faf7a89c72e4ab0
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Auto-completion: Call ..._last_table where needed
Until now, the '..._last_table' function ran everytime. This function is
responsible for populating the $last_table variable. Which means there
has been a valid FITS or plaintext table file called in the commandline.
Since we do not need to check for this everytime the script runs, I have
moved it to more specific places where we need to check the $last_table
variable. This might help reduce overhead.
Also, I noticed and removed the extra space between the command prompt
and the user commands.
---
bin/table/completion.bash | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/bin/table/completion.bash b/bin/table/completion.bash
index 7721469..472549f 100644
--- a/bin/table/completion.bash
+++ b/bin/table/completion.bash
@@ -386,7 +386,7 @@ _gnuastro_autocomplete_list_options(){
_gnuastro_autocomplete_print_message(){
if ! [ x"$1" = x ]; then
printf "\n$1\n"
- printf "${PS1@P} %s" "$COMP_LINE"
+ printf "${PS1@P}%s" "$COMP_LINE"
fi
}
@@ -426,10 +426,7 @@ _gnuastro_asttable_completions(){
prev="${COMP_WORDS[COMP_CWORD-2]}"
fi
- # If a table has been called until this stage, extract it. The table
- # name itself will be put in 'last_table' and its possible HDU (if its
- # was a FITS table), will be put in 'last_table_hdu'.
- _gnuastro_autocomplete_last_table
+
case "$prev" in
@@ -438,6 +435,11 @@ _gnuastro_asttable_completions(){
_gnuastro_autocomplete_list_options $PROG_NAME
;;
-i|--information)
+ # If a table has been called until this stage, extract it. The
table
+ # name itself will be put in 'last_table' and its possible HDU (if
its
+ # was a FITS table), will be put in 'last_table_hdu'.
+ _gnuastro_autocomplete_last_table
+
# when a file has been given before this, and the
# '--information' option is called, we should tell the user to
# avoid trying new options and just press ENTER. Otherwise, we
@@ -461,10 +463,12 @@ _gnuastro_asttable_completions(){
# file specified in the commandline. If no fits files were
# detected, there will be no response from autocompletion. This
# might alert the user that something is going wrong.
+ _gnuastro_autocomplete_last_table
_gnuastro_autocomplete_list_fits_columns "$last_table"
;;
-W|--wcshdu|-u|--catcolumnhdu|-h|--hdu)
# Description is same as the '--column' option.
+ _gnuastro_autocomplete_last_table
_gnuastro_autocomplete_list_fits_hdu "$last_table"
;;
-o|--output|--polygon|-H|--head|-t|--tail| \
@@ -482,10 +486,12 @@ _gnuastro_asttable_completions(){
# safely press ENTER since this configuration disables all
# other options. Otherwise, just print all available options.
if echo "$COMP_LINE" \
- | grep -e ' --information' -e ' -i' &> /dev/null \
- && [ x"$last_table" ]; then
- _gnuastro_autocomplete_print_message "$infowarning"
- COMPREPLY=()
+ | grep -e ' --information' -e ' -i' &> /dev/null; then
+ _gnuastro_autocomplete_last_table
+ if [ x"$last_table" ]; then
+ _gnuastro_autocomplete_print_message "$infowarning"
+ COMPREPLY=()
+ fi
else
_gnuastro_autocomplete_list_options $PROG_NAME
fi
- [gnuastro-commits] master 6efd4ff 32/62: Book: Add auto-complete to the developing section, (continued)
- [gnuastro-commits] master 6efd4ff 32/62: Book: Add auto-complete to the developing section, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 0e382bc 11/62: Table: Completion, suggest columns inside fits, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 328ab31 19/62: Table: Completion, thoughts on short options, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master b5c4f29 27/62: Table: Completion, add options, improve get name, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 86df9d8 25/62: Table: Completion, custom compgen, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 51daecd 30/62: Table: Completion, update copyright, minor edits, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master e690fc5 37/62: Bash completion: renamed fixed file to completion.bash, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 229ac51 41/62: /bin/table/completion.bash: Refactor code, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 50026ec 48/62: Auto-completion: Rename boolean query functions, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 8150e1c 50/62: Auto-completion: Refactor FITS related functions, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master afadccf 52/62: Auto-completion: Call ..._last_table where needed,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 90f08c2 53/62: Auto-completion: Refactor ..._is_table function, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 4598eba 54/62: Auto-completion: clean re-implementation for Table, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 59669d9 61/62: Book: new section on known issues with Crop, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master b947f79 62/62: TAB completion: enabled in Fits program, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master acf58c1 58/62: TAB completion: now supported in ConvertType and Convolve, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 9ae830f 34/62: Table: Completion, replace double negative, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 7f1a203 35/62: Book: Autocompletion for developers example, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 6379566 36/62: Book: edits to the Bash auto-completion section, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 9335953 44/62: Auto-completion: Faster fits parse, use 'local', Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 284a32e 51/62: Auto-completion: Debug -i, improve performance, Mohammad Akhlaghi, 2021/05/13