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: Pedram Ashofteh Ardakani
Subject: [task #15799] Add the autocomplete feature to gnuastro
Date: Thu, 4 Mar 2021 16:57:49 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0

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

Hi Mohammad!

I have pushed three new commits on the dev-auto-complete branch
<https://codeberg.org/gnuastro/gnuastro/commits/branch/dev-auto-complete>.
Also, after lots of investigation to no avail, I started asking if it is
possible to control and manipulate the bash autocomplete output formatting.
<https://stackoverflow.com/q/66483519/6474744>

I have opened a new task <https://savannah.gnu.org/task/index.php?15910> to
add a unit test script that checks on our completion script.

Please let me know if things are looking good :)

Cheers

P.S. Commit Messages:
----

Auto-completion: Refactor ..._is_table function

With this commit, I replaced 'return 0' (or 1) with 'break' as it used to
be. Because we are not using the function as a boolean query. However, we
can se if there is a valid FITS or plaintext file withing the command
line by checking if the $last_table is populated: [ x$last_table != x ]

Also, I replaced an indented 'if' with 'elif' for better code readablity.

----

 Auto-completion: Call ..._last_table where needed

Until now, the '..._last_table' function ran everytime. This function is
responsible for populating the $last_table variable. Which means there
has been a valid FITS or plaintext table file called in the commandline.
Since we do not need to check for this everytime the script runs, I have
moved it to more specific places where we need to check the $last_table
variable. This might help reduce overhead.

Also, I noticed and removed the extra space between the command prompt
and the user commands.

----

 Auto-completion: Debug -i, improve performance

Until now, autocompletion checked if there is a valid FITS file or a
plaintext table available while also the '-i' or '--information' option
is called. In this case, it would print a warning message that it is safe
to press ENTER since all other options will be disabled by the 'table'
program. However, this behavior broke in previous commits. This commit
fixes the problem.

Also, previously the 'awk' command in the '..._last_table' function would
print all the words in the command line -- named as 'token'. This
includes the short and long options. The problem is that bash is later
instructed to check if each 'token' is a valid file -- [ -f $token]. As
Mohammad pointed out before, this is a computationaly exhaustive process.
So, we would only need to check tokens that we already know are not the
program options! These tokens would start with a dash '-'. Hence, I have
added a regex condition check in the 'awk' program to take care of that.
Now, it will only print tokens NOT starting with a '-' sign.

    _______________________________________________________

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]