gnuastro-devel
[Top][All Lists]
Advanced

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

[task #15799] Add the autocomplete feature to gnuastro


From: Mohammad Akhlaghi
Subject: [task #15799] Add the autocomplete feature to gnuastro
Date: Sun, 28 Feb 2021 20:18:46 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0

Follow-up Comment #22, task #15799 (project gnuastro):

Thanks a lot Pedram, I made some modifications in Commit 2f43d29151f
<https://codeberg.org/gnuastro/gnuastro/commit/2f43d29151f> (message in P.S.,
this was a good idea!)

In the case that '--information' is called before a file is given, we do
indeed want to list all possible tables. But don't forget that tables can also
be plain-text files (not just FITS). So we need a new function (maybe called
'_gnuastro_autocomplete_file_is_table'). Can you implement it? All its
components are already there ;-).

In short, we want to get a listing of all the files in this directory and pass
them through this function so we only suggest files that are tables. The
'_gnuastro_autocomplete_plaintext_is_table' function will already do the check
for non-FITS files. For FITS files, you can use `astfits FILE.FITS -q` and
look into the third column, if it has a 'table' in any of the rows/HDUs, you
can show that file, otherwise, don't bother showing it! 

This will be SO USEFUL! When we have a directory with image and table files,
when we call 'asttable' and press TAB, we only see the tables :-D!

Another suggestion: after playing a little with it, I feel that mixing options
and file names is very annoying! Now that we can print our own terminal
prompt, can you implement a feature like this: when listing options, files and
directories, we separate them like this:


astfits <TAB><TAB>

DIRECTORIES
a/    b/    c/

FILES
a.fits  b.fits c.fits

OPTIONS
--column --information --quiet ...


We can use the 'column' command to sort the outputs into columns internally.
For the titles, we can also give different shell colors
<https://techstop.github.io/bash-script-colors/> and make them bold. This will
allow us to remove the empty lines. Ofcourse, when no directories, files or
options are present, we can remove the title also.

It is becoming EXTREMELY USEFUL and I am really excited to be so close to
implementing this in all the programs!


P.S.Commit message:

Auto-completion: Minor polishing of the warning message

Until now, the warning message for the '--information' option was a single
string that was repeated in two places (adding a check for it in general
was a good idea Pedram!). However, based on previous experience, this can
cause bugs if we later edit one of them and forget to the edit the other!

With this commit a new 'infowarning' variable is defined at the top of the
function and message is put there. That variable can now be used anywhere
in the code, and all the time it will have the same value.

Other changes with this commit:

 - When the 'last_table' variable is not empty, the existance of its file
   has already been checked. So we should just check if its an empty string
   or not. Don't forget that checking the existance of a file is
   computationally expensive (requires Bash to leave its internal
   evironment and go to the operating system!).

 - In my case the previous '$' wasn't enough to print the prompt. The new
   line simply started with a '$' sign, not my standard prompt. So I added
   '${PS1@P}'. As mentioned above it, there is a portability issue here
   with older Bash systems. We should find a more portable solution.

 - I removed the extra '-----' lines: they are distracting and waste a lot
   of valuable terminal lines ;-)!

[To help in future reference to commits related to auto-completion, let's
start the commit title with 'Auto-completion'.]

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/task/?15799>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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