gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 477d23d 06/62: Rename completion files


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 477d23d 06/62: Rename completion files
Date: Thu, 13 May 2021 22:20:45 -0400 (EDT)

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

    Rename completion files
    
    * Until now, I was just working on the CosmicCalculator program. With
      this commit, I will start my work on the Table program. This is
      because the Table program accepts a variety of inputs, which means its
      completion script can be used as a template for all other programs.
---
 ...{astcosmiccal-completion.bash => completion.sh} |  0
 .../completion.sh}                                 | 56 ++++++++++++++++++++--
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/bin/cosmiccal/astcosmiccal-completion.bash 
b/bin/cosmiccal/completion.sh
similarity index 100%
copy from bin/cosmiccal/astcosmiccal-completion.bash
copy to bin/cosmiccal/completion.sh
diff --git a/bin/cosmiccal/astcosmiccal-completion.bash 
b/bin/table/completion.sh
similarity index 55%
rename from bin/cosmiccal/astcosmiccal-completion.bash
rename to bin/table/completion.sh
index 9205b43..edb26dd 100644
--- a/bin/cosmiccal/astcosmiccal-completion.bash
+++ b/bin/table/completion.sh
@@ -4,7 +4,47 @@
 # this specific program (i.e. astcosmiccal):
 # $ source astcosmiccal-completion.bash
 
-_astcosmiccal_completions(){
+# GLOBAL VARIABLES
+
+PREFIX="/usr/local/bin";
+ASTFITS="$PREFIX/astfits";
+ASTTABLE="$PREFIX/asttable";
+
+#  astquery gaia --dataset=edr3 --center=24,25 --radius=0.1 --output=gaia.fits 
--column=ra,dec,parallax --quiet -i | awk '/[0-9]+/ {print $2}'
+
+_gnuastro_autocomplete_fits_hdu_read(){
+    $("$ASTFITS --quiet $1" | awk '{print $2}')
+}
+
+_gnuastro_autocomplete_fits_list(){
+
+}
+
+_gnuastro_autocomplete_column_read(){
+
+}
+
+_gnuastro_autocomplete_expect_number(){
+    # Prompt the user that this option only accepts a number
+}
+
+_gnuastro_fits_last_occurance(){
+    # The last FITS file in COMP_LINE
+
+}
+
+_gnuastro_file_last_occurance(){
+    # The last file name (.txt/.fits) in COMP_LINE
+}
+
+_gnuastro_asttable_completions(){
+
+
+
+    # TODO: @@
+    PROG_NAME="asttable";
+
+    PROG_ADDRESS="$PREFIX/$PROG_NAME";
 
     # Initialize the completion response with null
     COMPREPLY=();
@@ -16,20 +56,28 @@ _astcosmiccal_completions(){
     local prev="${COMP_WORDS[COMP_CWORD-1]}";
 
     # Create the array of options that need a fits file as input
-    local infits=($(astcosmiccal --help | \
+    local infits=($($PROG_ADDRESS --help | \
                                    awk 'match($0, 
/--([A-Z]|[a-z]|[0-9])*=FITS/) {print substr($0, RSTART, RLENGTH-4)}'));
 
+#    case "$1" in
+#        -h|--hdu)
+#        # default case
+#        *) ;;
+#    esac
+
     # Add completion suggestions for special options
     if [ $prev = "--lineatz" ]; then
         # Show all sub options in "lineatz"
-        COMPREPLY+=($(compgen -W "$(astcosmiccal --listlines | \
+        COMPREPLY+=($(compgen -W "$($PREFIX/$PROG_NAME --listlines | \
                              awk '!/^#/ {print $2}') " \
                               -- "$word"));
     fi
 
     # Add completion suggestions for general options
     if [[ "${infits[@]}" =~ "$prev" ]]; then
+
         # Check if the previous word exists in the "infits" array
+        # Look into 'gal_fits_name_is_fits' function for acceptable suffixes
         COMPREPLY+=($(compgen -f -X "!*.[fF][iI][tT][sS]"));
     else
         # Show all options in CosmicCalculator:
@@ -39,4 +87,4 @@ _astcosmiccal_completions(){
     fi;
 }
 
-complete -F _astcosmiccal_completions astcosmiccal
+complete -F _asttable_completions asttable



reply via email to

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