gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 04ee1fe 46/62: Auto-completion: Suggest plaint


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 04ee1fe 46/62: Auto-completion: Suggest plaintext tables too
Date: Thu, 13 May 2021 22:20:53 -0400 (EDT)

branch: master
commit 04ee1feeed6ac407d548a1bd4533c8dbbc065340
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Auto-completion: Suggest plaintext tables too
    
    Until now, autocomplete only suggested FITS files as input. With this
    commit, plaintext files will be shown too.
    
    Also, I have added the _gnuastro_autocomplete_list_all_valid_files
    function to prevent redundant iteration over a list of files to check
    for all acceptable file types.
---
 bin/table/completion.bash | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/bin/table/completion.bash b/bin/table/completion.bash
index b98278e..907c184 100644
--- a/bin/table/completion.bash
+++ b/bin/table/completion.bash
@@ -133,6 +133,31 @@ _gnuastro_autocomplete_list_fits_names(){
 
 
 
+_gnuastro_autocomplete_list_plaintext_tables(){
+    local files=($(ls | grep -e "^$word" --color=never))
+    for f in ${files[*]} ; do
+        if _gnuastro_autocomplete_plaintext_is_table "$f"; then
+            COMPREPLY+=("$f"); fi
+    done
+}
+
+
+
+
+# List all files that are considered as valid input. This is here to
+# prevent going throught a list of files serveral times for each extension.
+_gnuastro_autocomplete_list_all_valid_files(){
+    local files=($(ls | grep -e "^$word" --color=never))
+    for f in ${files[*]} ; do
+        if _gnuastro_autocomplete_plaintext_is_table "$f"; then
+            COMPREPLY+=("$f"); fi
+        if $_gnuastro_astfits "$f" -q &> /dev/null; then COMPREPLY+=("$f"); fi
+    done
+}
+
+
+
+
 # Prompt the user that this option only accepts a number
 _gnuastro_autocomplete_expect_number(){
     echo "Pass"
@@ -421,7 +446,7 @@ _gnuastro_asttable_completions(){
             # should let the user choose a FITS table (to view its
             # information).
             if [ x"$last_table" = x ]; then
-                _gnuastro_autocomplete_list_fits_names
+                _gnuastro_autocomplete_list_all_valid_files
             else
                 _gnuastro_autocomplete_print_message "$infowarning"
                 COMPREPLY=()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]