# bash completions for libgrib-api-tools, as of 1.14.5 
# Alastair McKinstry <mckinstry@debian.org>,


# Usage: grib_info [-v] [-d] [-t]

#Usage: grib_cmp file file

grib_key_types=$(grib_keys -L)

complete -W "-v -d -t " -f grib_info

complete -W  "-f -r -p -P -w -B -V -w -g -G -7 -v" -f grib_copy
#USAGE
#grib_copy [options] grib_file grib_file ... output_grib_file
#
#OPTIONS
#-f Force. Force the execution not to fail on error.
#-r Repack data. Sometimes after setting some keys involving properties
#of the packing algorithm a repacking of data is needed.
#This repacking is performed setting this -r option.
#-p key[:{s/d/l}],key[:{s/d/l}],...
#Declaration of keys to print.
#For each key a string (key:s) or a double (key:d) or a long (key:l)
#type can be requested. Default type is string.
#-P key[:{s/d/l}],key[:{s/d/l}],...
#As -p adding the declared keys to the default list.
#-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]=value,...
#Where clause.
#Only grib messages matching the key/value constraints are copied to the
#output_grib_file.
#A valid constraint is of type key=value or key!=value.
#For each key a string (key:s) or a double (key:d) or a long (key:l)
#type can be defined. Default type is string.
#-B order by directive
#Order by. The output will be ordered according to the order by directive.
#Order by example: "step asc, centre desc" (step ascending and centre descending)
#-V Version.
#-W width
#Minimum width of each column in output. Default is 10.
#-M Multi-field support off. Turn off support for multiple fields in single grib message.
#-T T | B | ANDMessage type. T->GTS, B->BUFR, A->Any (Experimental).
#The input file is interpreted according to the message type.
#-g Copy GTS header.
#-G GRIBEX compatibility mode.
#-7 Does not fail when the message has wrong length
#-v Verbose.
#"""
#

complete -W "-T -G -x -c -L -a " -f grib_keys
# grib_keys -T <type> -F <file> -x -c -L -a 

# grib2ppm -u [-f <num>] [ -l <num>]  [ -m <colrmapfile> ] file
# TODO: complete
complete -W "-u -f -l -m " -f grib2ppm

# grib_add:  in1 [in2 ... ]  out
# TODO: complete. 

# usage: /usr/bin/grib1to2 [-f] in.grib1 out.grib2
# -f   convert to grib2 only typeOfLevel='hybrid' and copy other level types as grib1

#usage: grib_corruption_check gribfile

#usage: grib_count [-v] infile1 infile2 ...


# 	grib_debug [options] grib_file grib_file ...
# Options: [-V] [ -7] [-G] [-T T|B|A] <file>


#	grib_debug [options] grib_file grib_file ...
# options [-V] [-7] [-G] [-T T|B|A] <file>

#grib_distance:  in1 [in2 ... ]  out 

# grib_histogram:  in1 [in2 ... ]  out

# grib_dump [options] grib_file grib_file ...
# options:
# [-O] [-D] [-d] [-j] [-C] [-t] [-H] [-a] [-M] [-7] [-V] [-x] [-X offset]
#  [-w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,...] 
# -s key[:{s/d/l}]=value,key[:{s/d/l}]=value,..
# -T T | B | A

# grib_error: [-d] [-e err] [-o out] file1 file2

# grib_filter [options] rules_file grib_file grib_file ...
# [-f] [-o <output_file> ] [-M] [-V] [-g] [-G] [-T T|B|A ] [-7] [-v]

# grib_get [options] grib_file grib_file ...
# [ -f ] [ -F <format> ] [ -l Latitude,Longitude[,MODE,file]  [-M] [-V] [-g] [-G] [-T T|B|A ] [-7] [ -i <index> ] [ -X <offset]
# -p key[:{s/d/l}],key[:{s/d/l}],...
# -P key[:{s/d/l}],key[:{s/d/l}],...
# -w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,...
# -n <namespace>
# -s key[:{s/d/l}]=value,key[:{s/d/l}]=value,..
# -w <width>
# -m 

# grib_get_data [options] grib_file grib_file ...
# [-M] [f] [ -G] [ -7] [-V] [ -X offset ] 
# -m missingValue
# -p key[:{s/d/l}],key[:{s/d/l}],..
# -F format 
# -w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,...

# grib_index_build [options] grib_file grib_file ...
# [ -f] [ -V ] [ T T|B|A ] [ -M ] [ -N ] [ -k key1,key2, .. ] [ -o <output_file> ]

# usage: grib_info [-v] [-d] [-t]

# grib_keys [options]
# [ -T <type> ] [ -F <file> ] [ -t ] [ -a ] [ -c ] [ -x ] [ -L ]

# grib_list_keys <files>

# grib_ls [options] grib_file grib_file ...
# [ -F format ] [ -j ] [ -i <index ] [ -n <namespace> ] [-m] [ -V] [ -w <width> ] [ -M ] [ -g] [ -T T|B|A ] [ -7] [ -X offset ] [ -x] 
# 	-B order by directivea
# -l Latitude,Longitude[,MODE,file]
# -s key[:{s/d/l}]=value,key[:{s/d/l}]=value,...
# -p key[:{s/d/l}],key[:{s/d/l}],...
# -P key[:{s/d/l}],key[:{s/d/l}],...
# -w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]{=/!=}value,...

# usage: grib_moments split order interpolated.grib original.grib

 # grib_packing [-n minimum] [-x maximum] [-b number of bits] [-d decimal scaling] [-2] [--] [values ..]

# grib_parser <file>

# Usage: grib_repair in out [bad]

#grib_set [options] grib_file grib_file ... output_grib_file 
# -s key[:{s/d/l}]=value,key[:{s/d/l}]=value,...
# [ -r] [ -d data ] [ -7 ] [ -S ] [ -V] [ -M] [ -g] [ -G] [ -T T|B|A] [ -f] [ -v] 
# -d value
# -p key[:{s/d/l}],key[:{s/d/l}],...
# -P key[:{s/d/l}],key[:{s/d/l}],...
# -w key[:{s/d/l}]{=/!=}value,key[:{s/d/l}]=value,...

# grib_to_json [files] 



