This repository has been archived by the owner on Oct 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathlemon-completion.sh
200 lines (173 loc) · 4.22 KB
/
lemon-completion.sh
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#! bash
#
# Bash completion support for LEMON (commands and --long-options)
#
# Copyright (c) 2013 Victor Terron. All rights reserved.
# Institute of Astrophysics of Andalusia, IAA-CSIC
# Distributed under the GNU General Public License, version 3.0
# To use these completion routines:
# 1) Copy this file to somewhere (e.g. ~/.lemon-completion.sh).
# 2) Add the following line to your .bashrc/.zshrc:
# source ~/.lemon-completion.sh
shopt -s extglob
FITS_EXTS="fit?(s)|FIT?(S)"
JSON_EXTS="json|JSON"
LEMONDB_EXTS="LEMONdB|lemondb"
# Match the current word against the list given as argument
_match()
{
COMPREPLY=( $(compgen -W "${1}" -- ${cur}) )
}
_lemon_import()
{
local opts
opts="--object --pattern --counts --filename --follow --exact
--datek --timek --expk= --objectk --uik"
if [[ ${cur} != -* ]]; then
_filedir @($FITS_EXTS)
else
_match "${opts}"
fi
}
_lemon_seeing()
{
local opts
opts="--filename --maximum --margin --snr-percentile --mean
--sources-percentile --suffix --overwrite --cores --verbose
--fsigma --fwhm_dir --esigma --elong_dir --coaddk --fwhmk"
if [[ ${cur} == -* ]]; then
_match "${opts}"
else
_filedir @($FITS_EXTS)
fi
}
_lemon_mosaic()
{
local opts
opts="--overwrite --background-match --no-reprojection --combine
--filter --cores --filterk"
if [[ ${cur} == -* ]]; then
_match "${opts}"
elif [[ ${prev} == --combine ]]; then
_match "mean median count"
else
_filedir @($FITS_EXTS)
fi
}
_lemon_astrometry()
{
local opts
opts="--radius --blind --timeout --suffix --cores -o --verbose --rak --deck"
if [[ ${cur} == -* ]]; then
_match "${opts}"
else
_filedir @($FITS_EXTS)
fi
}
_lemon_annuli()
{
local opts
opts="--overwrite --margin --gain --cores --verbose --aperture
--annulus --dannulus --min-sky --constant --minimum-constant
--lower --upper --step --sky --width --snr-percentile --mean
--maximum --minimum-images --minimum-stars --pct
--weights-threshold --max-iters --worst-fraction -objectk
--filterk --datek --timek --expk --coaddk --gaink --fwhmk
--airmk --uik"
if [[ ${cur} == -* ]]; then
_match "${opts}"
else
# Input FITS images / output JSON file
_filedir @($FITS_EXTS|$JSON_EXTS)
fi
}
_lemon_photometry()
{
local opts
opts="--overwrite --filter --exclude --cbox --maximum --margin
--gain --annuli --cores --verbose --coordinates --epoch --aperture
--annulus --dannulus --min-sky --individual-fwhm --aperture-pix
--annulus-pix --dannulus-pix --snr-percentile --mean --objectk
--filterk --datek --timek --expk --coaddk --gaink --fwhmk --airmk
--uik"
case $prev in
--annuli)
_filedir @($JSON_EXTS)
return 0
;;
--coordinates)
_filedir
return 0
;;
esac
if [[ ${cur} == -* ]]; then
_match "${opts}"
else
# Input FITS images / output LEMONdB
_filedir @($FITS_EXTS|$LEMONDB_EXTS)
fi
}
_lemon_diffphot()
{
local opts
opts="--overwrite --cores --verbose --minimum-images --stars
--minimum-stars --pct --weights-threshold --max-iters --worst-fraction"
if [[ ${cur} == -* ]]; then
_match "${opts}"
else
_filedir @($LEMONDB_EXTS)
fi
}
_lemon_juicer()
{
_filedir @($LEMONDB_EXTS)
}
_lemon()
{
local cur prev commands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="import seeing astrometry mosaic annuli photometry
diffphot juicer"
# The options that autocomplete depend on the LEMON command being
# executed. For example, the '--exact' option is specific to the
# 'import' command, so it must be available only when that is the
# second word in the current command line (i.e., 'lemon import ...')
case "${COMP_WORDS[1]}" in
import)
_lemon_import
return 0
;;
seeing)
_lemon_seeing
return 0
;;
mosaic)
_lemon_mosaic
return 0
;;
astrometry)
_lemon_astrometry
return 0
;;
annuli)
_lemon_annuli
return 0
;;
photometry)
_lemon_photometry
return 0
;;
diffphot)
_lemon_diffphot
return 0
;;
juicer)
_lemon_juicer
return 0
;;
esac
_match "${commands}"
}
complete -F _lemon lemon