Request for Changes-42: Generator for completion scripts

From OTBWiki
Jump to: navigation, search

Status

Summary

This RFC contains the addition of a small generator for completion script. This completion script is intended to work with all otbcli_* applications. It will propose completion for the keys names. In addition, there is also completion on choice parameters.

Rationale

This development was made during OSGeo Paris code sprint 2016. The idea was to facilitate the use of command line application with convenient completions.

Implementation details

Classes and files

M       CMakeLists.txt
A       Utilities/Completion/CMakeLists.txt
A       Utilities/Completion/completionGenerator.cxx

The completion is enabled when your current word start with a '-', or when your previous word is a choice key. Otherwise, the default completion on paths is used.

The generator is a small main located in Utilities/Completion. It loads all available applications, get their parameter list and generate a single completion script for all applications. This script is produced in the build directory : otbcli_completion. There is a specific target to compile and generate the script : generate-completion.

The script can be deployed according to the system preferences (for instante in /etc/bash_completion.d)

Here is an example of completions generated :

$ bin/otbcli_ColorMapping -[TAB][TAB]
-in                         -method.continuous.lut      -method.custom.lut          -method.image.nodatavalue   -op                         -outxml
-inxml                      -method.continuous.max      -method.image.in            -method.image.up            -op.colortolabel.notfound   -ram
-method                     -method.continuous.min      -method.image.low           -method.optimal.background  -out                        
$ bin/otbcli_ColorMapping -method c[TAB][TAB]
continuous  custom      

Applications

Tests

Documentation

Additional notes