[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master a829b24 05/62: Completion: Suggest FITS files
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master a829b24 05/62: Completion: Suggest FITS files in relevant options |
Date: |
Thu, 13 May 2021 22:20:45 -0400 (EDT) |
branch: master
commit a829b241f300cbf05ed64a03eeaf9c7ec0448f98
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Completion: Suggest FITS files in relevant options
Until now, the completion did not suggest `FITS` files for relevant
options. With this commit when user types in the following command:
`astconvolve --kernel <TAB><TAB>`, suggestion includes only the files
present in the current directory that have the `FITS` extension.
It is worth to note that the `FITS` extension is set to be case
insensitive.
Also, now the suggestions are architectured differently. In more
details, suggestions are added to the `COMP_REPLY` array using the `+=`
operator. This is to prevent confusions and incomplete suggestions for
situations that the word being completed can satifsy two or more
conditions.
---
bin/cosmiccal/astcosmiccal-completion.bash | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/bin/cosmiccal/astcosmiccal-completion.bash
b/bin/cosmiccal/astcosmiccal-completion.bash
index e22723a..9205b43 100644
--- a/bin/cosmiccal/astcosmiccal-completion.bash
+++ b/bin/cosmiccal/astcosmiccal-completion.bash
@@ -15,14 +15,25 @@ _astcosmiccal_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=($(astcosmiccal --help | \
+ awk 'match($0,
/--([A-Z]|[a-z]|[0-9])*=FITS/) {print substr($0, RSTART, RLENGTH-4)}'));
+
+ # Add completion suggestions for special options
if [ $prev = "--lineatz" ]; then
# Show all sub options in "lineatz"
- COMPREPLY=($(compgen -W "$(astcosmiccal --listlines | \
+ COMPREPLY+=($(compgen -W "$(astcosmiccal --listlines | \
awk '!/^#/ {print $2}') " \
- -- "$word"));
+ -- "$word"));
+ fi
+
+ # Add completion suggestions for general options
+ if [[ "${infits[@]}" =~ "$prev" ]]; then
+ # Check if the previous word exists in the "infits" array
+ COMPREPLY+=($(compgen -f -X "!*.[fF][iI][tT][sS]"));
else
# Show all options in CosmicCalculator:
- COMPREPLY=($(compgen -W "$(astcosmiccal --help | \
+ COMPREPLY+=($(compgen -W "$(astcosmiccal --help | \
awk 'match($0, /--([A-Z]|[a-z]|[0-9])*/) {print
substr($0, RSTART, RLENGTH)}') " \
-- "$word"));
fi;
- [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 <=
- [gnuastro-commits] master 3da00c3 07/62: Table: Prepare initial completion script, Mohammad Akhlaghi, 2021/05/13
- [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