[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 3da00c3 07/62: Table: Prepare initial completi
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 3da00c3 07/62: Table: Prepare initial completion script |
Date: |
Thu, 13 May 2021 22:20:45 -0400 (EDT) |
branch: master
commit 3da00c3c669430aab704feb4455bf85d28385f39
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Table: Prepare initial completion script
* Until now, the Table program had no completion script. With this
commit, I will start to write the completion script.
---
bin/table/completion.sh | 59 ++++++++++++++++++-------------------------------
1 file changed, 21 insertions(+), 38 deletions(-)
diff --git a/bin/table/completion.sh b/bin/table/completion.sh
index edb26dd..91c8ceb 100644
--- a/bin/table/completion.sh
+++ b/bin/table/completion.sh
@@ -13,33 +13,38 @@ 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}')
+ # Accepts a fits filename as input and suggests its headers
+ COMPREPLY=($("$ASTFITS --quiet $1" | awk '{print $2}'))
}
-_gnuastro_autocomplete_fits_list(){
-
+_gnuastro_autocomplete_fits_list_files(){
+ # Suggest all 'FITS' files in current directory. Case insensitive.
+ COMPREPLY+=($(compgen -f -X "!*.[fF][iI][tT][sS]"));
}
_gnuastro_autocomplete_column_read(){
-
+ echo "Pass"
}
_gnuastro_autocomplete_expect_number(){
# Prompt the user that this option only accepts a number
+ echo "Pass"
}
_gnuastro_fits_last_occurance(){
# The last FITS file in COMP_LINE
-
+ echo "Pass"
}
_gnuastro_file_last_occurance(){
# The last file name (.txt/.fits) in COMP_LINE
+ echo "Pass"
}
-_gnuastro_asttable_completions(){
-
+# just find the short commands
+# astconvolve --help | awk -v pattern="^ *-([a-z]|[A-Z])" 'match($0, pattern)
{print $0}'
+_gnuastro_asttable_completions(){
# TODO: @@
PROG_NAME="asttable";
@@ -55,36 +60,14 @@ _gnuastro_asttable_completions(){
# Variable "prev" is the word just before the current word
local prev="${COMP_WORDS[COMP_CWORD-1]}";
- # Create the array of options that need a fits file as input
- 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 "$($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:
- COMPREPLY+=($(compgen -W "$(astcosmiccal --help | \
- awk 'match($0, /--([A-Z]|[a-z]|[0-9])*/) {print
substr($0, RSTART, RLENGTH)}') " \
- -- "$word"));
- fi;
-}
+ case "$1" in
+ -i|--information)
+ _gnuastro_autocomplete_fits_list_files
+ ;;
+ -b|--noblank) ;;
+ -h|--hdu) ;;
+ # default case
+ *) ;;
+ esac
complete -F _asttable_completions asttable
- [gnuastro-commits] master updated (ffc7608 -> b947f79), Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 1c1fe3d 01/62: New feature: Auto Complete (WIP), Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master c02ae2c 02/62: Completion: feed options from `help`, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master b06fbce 03/62: Completion: Fix indentations, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master a829b24 05/62: Completion: Suggest FITS files in relevant options, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 3da00c3 07/62: Table: Prepare initial completion script,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 477d23d 06/62: Rename completion files, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 39efeea 08/62: Table: First working completion, general commands, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 32cbe32 13/62: Table: Completion, better formatting, add function, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master d631f5b 15/62: Table: Completion, remove global variables, etc, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master f4cf33d 17/62: Tabel: Completion, examine for fits availability, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master e1c1a4b 18/62: Table: Completion, fix 'wcshdu', Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 6fe9cb6 20/62: Table: Completion, refactor awk regex fits name, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master c593823 23/62: Table: Completion, fix hdu and fits suggestions, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 0420521 04/62: Completion: bug fix in catching the options, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 3d8e96d 10/62: Table: Fix completion issue, Mohammad Akhlaghi, 2021/05/13