[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master c02ae2c 02/62: Completion: feed options from `
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master c02ae2c 02/62: Completion: feed options from `help` |
Date: |
Thu, 13 May 2021 22:20:44 -0400 (EDT) |
branch: master
commit c02ae2c7efb17def0091dd35847d76f86750c9a6
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Completion: feed options from `help`
Until now, the completion options were fed from the `args.h` file of the
corresponding program. With this commit, completions will be fed through
the auto-generated `--help` option. This ensures that completion will be
kept up-to-date in each release of each program.
---
bin/cosmiccal/astcosmiccal-completion.bash | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/bin/cosmiccal/astcosmiccal-completion.bash
b/bin/cosmiccal/astcosmiccal-completion.bash
index 8e81306..c7479da 100644
--- a/bin/cosmiccal/astcosmiccal-completion.bash
+++ b/bin/cosmiccal/astcosmiccal-completion.bash
@@ -6,20 +6,6 @@
_astcosmiccal_completions(){
- # PATH_TO_COMMAND_BIN, i.e. the directory which the astcosmiccal
- # command sits in.
- local PATH_TO_COMMAND_BIN=".";
-
- # Use "args.h" file to filter out all valid options of the command and
- # put them all in the variable "commandoptions".
-
- local commandoptions=$(sed -n -E '/^\s+\"[a-z]+/p' \
- "$PATH_TO_COMMAND_BIN/args.h" | \
- # remove newline and space characters
- tr -d '\n" ' | \
- # replace commas with spaces
- tr ',' ' ');
-
# Initialize the completion response with null
COMPREPLY=();
@@ -29,13 +15,16 @@ _astcosmiccal_completions(){
# Variable "prev" is the word just before the current word
local prev="${COMP_WORDS[COMP_CWORD-1]}";
- if [ $prev = "lineatz" ]; then
- # Show options related to "lineatz"
+ if [ $prev = "--lineatz" ]; then
+ # Show all sub options in "lineatz"
COMPREPLY=($(compgen -W "$(astcosmiccal --listlines | \
awk '!/^#/ {print $2}') " \
-- "$word"));
else
- COMPREPLY=($(compgen -W "$commandoptions" -- "$word"));
+ # Show all options in CosmicCalculator:
+ COMPREPLY=($(compgen -W "$(astcosmiccal --help | \
+ awk 'match($0, /--[a-z]+/) {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 <=
- [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, 2021/05/13
- [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