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: Sun, 28 Feb 2021 16:38:11 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0

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

Hi Mohammad! OK, I pushed the commit 968bb7c07b
<https://codeberg.org/gnuastro/gnuastro/commit/968bb7c07ba610683053ddd539629579ba2069bf>
and changed the syntax a bit. Now it should be more clear :)
> [...] the user's prompt is no longer printed [...]
It should have printed the prompt in a new line :/ I used the command below to
print the prompt:

printf "%s" "$COMP_LINE"


A sample output:

[pedram@ardakani table]$ asttable gaia.fits --information                     
                                                         
The '--information' (or '-i') will disable all other options. You can safely
press ENTER now.                                         
------------------------                                                      
                                                       
$ asttable gaia.fits --information


Do you want me to print the part before '$' too? It is stored in '$PS1', I can
look it up and see if we can prepend it to the $COMP_LINE.

Would you mind just checking it again and letting me know if it works?

Cheers

=== Commit Message: 
<https://codeberg.org/gnuastro/gnuastro/commit/968bb7c07ba610683053ddd539629579ba2069bf>
===

/bin/table/completion.bash: Refactor code

Until now, I used a case inside an 'if' statement. The syntax looked
pretty confusing and redundant. In this commit, the completion script
will scan the entire prompt for '-i' or '--information' option. If it
finds any instances, it will check if there is a valid fits file
specified. If both cases are TRUE, the completion will print a message
and let the user know that s/he can press ENTER safely.

Also, I declared a new _gnuastro_autocomplete_print_message function.
This function will take only one argument, and pretty prints it. Then,
it will reprint the user prompt with a '$' at line beginning for a
natural and familiar experience.

Last but not least, I used 'grep' to scan the prompt. This is POSIX
compatible and easier to implement when there is more than one pattern
to check.

    _______________________________________________________

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]