1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
# Bash autocompletion to Gnuastro's Arithmetic program. See the comments
# above 'bin/completion.bash.in' for more.
#
# Original author:
# Mohammad Akhlaghi <mohammad@akhlaghi.org>
# Contributing author(s):
# Copyright (C) 2021-2025 Free Software Foundation, Inc.
#
# Gnuastro is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Gnuastro is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with Gnuastro. If not, see <http://www.gnu.org/
# For debugging
#
# See the description in 'bin/completion.bash.in'.
#source /PATH/TO/GNUASTRO/SRC/bin/completion.bash.in
#source /PATH/TO/GNUASTRO/BUILD/bin/completion.bash.built
#######################################################################
############ Only for Arithmetic (this program) ############
#######################################################################
# Dealing with arguments: Arithmetic only takes array/image files.
_gnuastro_autocomplete_astarithmetic_arguments(){
# Local variables to be filled by functions.
local arithmetic_lib_operators=""
local arithmetic_prog_operators=""
# Print all accessible images.
_gnuastro_autocomplete_compreply_files_certain image "$argument"
# If atleast one image has already been given, also print the
# arithmetic operators with the file names.
if _gnuastro_autocomplete_first_in_arguments image; then
# Fill the variables.
_gnuastro_autocomplete_compreply_arithmetic_lib
_gnuastro_autocomplete_compreply_arithmetic_prog
# Add them to COMPREPLY
_gnuastro_autocomplete_compreply_from_string \
"$arithmetic_lib_operators $arithmetic_prog_operators" \
"$argument"
fi
}
# Fill option value (depends on option).
_gnuastro_autocomplete_astarithmetic_option_value(){
# Internal variables.
local fits_file=""
local given_hdu=""
local given_file=""
# Keep this in the same order as the output of '--help', for options
# with similar operations, keep the order within the '|'s.
case "$option_name" in
-h|--hdu|-g|--globalhdu|-w|--wcshdu)
_gnuastro_autocomplete_given_file image ""
_gnuastro_autocomplete_compreply_hdus \
image "$given_file" "$current"
;;
-w|--wcsfile)
_gnuastro_autocomplete_compreply_files_certain image "$current"
;;
--interpmetric)
for v in radial manhattan; do COMPREPLY+=("$v"); done
;;
--tableformat)
_gnuastro_autocomplete_compreply_tableformat "$current"
;;
--wcslinearmatrix)
_gnuastro_autocomplete_compreply_wcslinearmatrix "$current"
;;
--numthreads)
_gnuastro_autocomplete_compreply_numthreads "$current"
;;
esac
}
_gnuastro_autocomplete_astarithmetic(){
# The installation directory of Gnuastro. The '@PREFIX@' part will be
# replaced automatically during 'make install', with the user's given
# requested installation directory. If you are debugging, please
# correct it yourself (usually to '/usr/local/bin', but don't commit
# this particular change).
local gnuastro_prefix="@PREFIX@"
# Basic initialization. The variables we want to remain inside this
# function are given a 'local' here and set inside the 'initialize'
# function. The variables are defined above the function that gives
# them a value.
local prev=""
local current=""
local argument=""
_gnuastro_autocomplete_initialize
# For a check
#echo
#echo "prev: $prev"
#echo "current: $current"
#echo "argument: $argument"
# Extract the current mode (if the user is giving an argument, option
# name, or option value). See the description above this function on
# how the mode is set.
local options_all=""
local option_name=""
local option_value=""
local option_name_complete=0
_gnuastro_autocomplete_mode
# For a check
#echo
#echo "argument: $argument"
#echo "option_name: $option_name"
#echo "option_name_complete: $option_name_complete"
#echo "option_value: $option_value"
# If 'option_name_complete==1', then we are busy filling in the option
# value.
if [ $option_name_complete = 1 ]; then
_gnuastro_autocomplete_astarithmetic_option_value
# When 'option_name' is not empty (and not yet complete), we are busy
# filling in the option name.
elif [ x$option_name != x ]; then
_gnuastro_autocomplete_compreply_options_all "$option_name"
# In the case of "none-of-the-above", it is an argument.
else
_gnuastro_autocomplete_astarithmetic_arguments
fi
}
# Define the completion specification, or COMPSPEC: -o bashdefault: Use
# Bash default completions if nothing is found. -F function: Use this
# 'function' to generate the given program's completion.
complete -o bashdefault -F _gnuastro_autocomplete_astarithmetic astarithmetic
|