[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master abe3ca6 43/62: Auto-completion: Smart list fit
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master abe3ca6 43/62: Auto-completion: Smart list fits files, fix var |
Date: |
Thu, 13 May 2021 22:20:52 -0400 (EDT) |
branch: master
commit abe3ca660feeaea3a46ff4b05f3739ea1acf7938
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Auto-completion: Smart list fits files, fix var
Until now, the function responsible for listing the fits files only
checked if the file extension ended with 'fits'. This is not a rebust
test, because other fits files -- that might have different extensions
or no extensions at all -- would be left out.
With this commit, I used 'astfits' program return value to check their
validity regardless of their name or extension. However, this has a bit
of overhead and slows response. We can ignore it if it is not that
significant, and will not ruin user experience.
Also, I replaced a hard-coded value with intended $inputfile variable.
---
bin/table/completion.bash | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/bin/table/completion.bash b/bin/table/completion.bash
index 3472301..694b95d 100644
--- a/bin/table/completion.bash
+++ b/bin/table/completion.bash
@@ -123,7 +123,14 @@ _gnuastro_autocomplete_list_fits_hdu(){
# The completion can not suggest filenames that contain white space in them
# for the time being.
_gnuastro_autocomplete_list_fits_names(){
- COMPREPLY+=($(compgen -f -X "!*.[fF][iI][tT][sS]" -- "$word"))
+ # List all files in the current directory. Filter out those that start
+ # with the current word in the command line '$word'. Note that the grep
+ # option '--color=never' has to be there to prevent passing special
+ # characters into '$COMPREPLY'.
+ local files=($(ls | grep -e "^$word" --color=never))
+ for f in ${files[*]} ; do
+ if astfits $f &> /dev/null; then COMPREPLY+=("$f"); fi
+ done
}
@@ -207,11 +214,11 @@ _gnuastro_autocomplete_option_value(){
_gnuastro_autocomplete_plaintext_is_table(){
# For easy reading.
- local inputfile=$1
+ local inputfile="$1"
# If the file is not plain-text, it will contain an 'executable' or
# 'binary' in the output of the 'file' command.
- if file samaeh-abstract.txt \
+ if file $inputfile \
| grep 'executable\|binary' &> /dev/null; then
return 1
else
- [gnuastro-commits] master e340452 42/62: Auto-completion: Minor polishing of the warning message, (continued)
- [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
- [gnuastro-commits] master d2bf2c2 60/62: TAB completion: updated documentation and polished the code, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 4412710 29/62: Table: Completions, add missing options from help, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 82e9692 33/62: Book: Update the auto-complete section, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master abe3ca6 43/62: Auto-completion: Smart list fits files, fix var,
Mohammad Akhlaghi <=
- [gnuastro-commits] master a66e8bb 57/62: TAB completion: BuildProgram support added, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master d7bf627 59/62: TAB completion: support added for CosmicCalculator and Crop, Mohammad Akhlaghi, 2021/05/13