[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 284a32e 51/62: Auto-completion: Debug -i, impr
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 284a32e 51/62: Auto-completion: Debug -i, improve performance |
Date: |
Thu, 13 May 2021 22:20:54 -0400 (EDT) |
branch: master
commit 284a32eb25310714f38bc64bd3152c2c0f19eddc
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Auto-completion: Debug -i, improve performance
Until now, autocompletion checked if there is a valid FITS file or a
plaintext table available while also the '-i' or '--information' option
is called. In this case, it would print a warning message that it is safe
to press ENTER since all other options will be disabled by the 'table'
program. However, this behavior broke in previous commits. This commit
fixes the problem.
Also, previously the 'awk' command in the '..._last_table' function would
print all the words in the command line -- named as 'token'. This
includes the short and long options. The problem is that bash is later
instructed to check if each 'token' is a valid file -- [ -f $token]. As
Mohammad pointed out before, this is a computationaly exhaustive process.
So, we would only need to check tokens that we already know are not the
program options! These tokens would start with a dash '-'. Hence, I have
added a regex condition check in the 'awk' program to take care of that.
Now, it will only print tokens NOT starting with a '-' sign.
---
bin/table/completion.bash | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/bin/table/completion.bash b/bin/table/completion.bash
index 5638665..7721469 100644
--- a/bin/table/completion.bash
+++ b/bin/table/completion.bash
@@ -273,7 +273,8 @@ _gnuastro_autocomplete_last_table(){
# Parse the tokens in reverse.
for token in $(echo "${COMP_WORDS[@]}" \
- | awk '{for(i=NF;i>1;--i) printf "%s ", $i}')
+ | awk '{for(i=NF;i>1;--i)
+ if ($i !~ /^-/) printf "%s ", $i}')
do
# First, make sure it is an existing file.
if [ -f $token ]; then
@@ -482,7 +483,7 @@ _gnuastro_asttable_completions(){
# other options. Otherwise, just print all available options.
if echo "$COMP_LINE" \
| grep -e ' --information' -e ' -i' &> /dev/null \
- && [ -f "$last_table" ]; then
+ && [ x"$last_table" ]; then
_gnuastro_autocomplete_print_message "$infowarning"
COMPREPLY=()
else
- [gnuastro-commits] master afadccf 52/62: Auto-completion: Call ..._last_table where needed, (continued)
- [gnuastro-commits] master afadccf 52/62: Auto-completion: Call ..._last_table where needed, Mohammad Akhlaghi, 2021/05/13
- [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 <=
- [gnuastro-commits] master e5707cd 28/62: Table: Completion, all options, update comments, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 88806f2 38/62: bin/table/completion.bash: improvements to find good table name, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 1bf469f 40/62: /bin/table/completion.bash: consider short opt '-i', Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master e340452 42/62: Auto-completion: Minor polishing of the warning message, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master e444941 45/62: Auto-completion: Call astfits/asttable consistently, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 04ee1fe 46/62: Auto-completion: Suggest plaintext tables too, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 3754f1b 47/62: Auto-completion: Human readable arguments, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master ea08fdb 49/62: Auto-completion: return value from last table, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master ece1614 55/62: Auto complete: separated generic functions from Table's recipe, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master ef351da 56/62: TAB completion: now working for Arithmetic, better infrastructure, Mohammad Akhlaghi, 2021/05/13