[GRASS-dev] Interface description flag

Hello,

(sorry if this gets posted multiple times, I'm having email problems at my end)

I'm developing an Emacs mode for interacting with the GRASS process,
available here:

https://bitbucket.org/tws/grass-mode.el/wiki/Home

One of the features of this mode is offering tab-completion of command
parameters. I use a lookup-table for this, populated by running all
the programs in the bin/ directory with the -interface-description
flag and parsing their output. This works fine for parameters that
have a set list of possible values, like d.vect icon.

However, I also have utility functions that provide completion of
vector and raster map names. I don't understand the output of
--interface-description well enough to know if there's a way to
automatically identify parameters that should be completed with a
vector name lookup. For example, all of the following combinations are
completed by a vector map file:

v.convert input= d.vect map= r.volume centroids= v.split input=

I notice that each of them has the following item in their <parameter> tag:

<gisprompt age="old" element="dig" prompt="vector" />

The age and element values differ, but all four have prompt="vector".

Can I use this to identify parameters that take a vector file name?
That is, is the value of <gisprompt prompt="vector"> present for all
commands that should be completed by a vector map name, and is this
value absent from all other parameters?

If not, is their another way to get this information directly from the programs?

Thanks for your help,

Tyler

Hello Tyler,
it's a bit of "black magic" that has historical roots. General
documentation how it should work is here:
http://grass.osgeo.org/programming7/gislib_cmdline_parsing.html#gisprompt_Member

Hope it helps for a start.
Maris.

2013/10/31 Tyler Smith <tyler@plantarum.ca>:

Hello,

(sorry if this gets posted multiple times, I'm having email problems at my end)

I'm developing an Emacs mode for interacting with the GRASS process,
available here:

https://bitbucket.org/tws/grass-mode.el/wiki/Home

One of the features of this mode is offering tab-completion of command
parameters. I use a lookup-table for this, populated by running all
the programs in the bin/ directory with the -interface-description
flag and parsing their output. This works fine for parameters that
have a set list of possible values, like d.vect icon.

However, I also have utility functions that provide completion of
vector and raster map names. I don't understand the output of
--interface-description well enough to know if there's a way to
automatically identify parameters that should be completed with a
vector name lookup. For example, all of the following combinations are
completed by a vector map file:

v.convert input= d.vect map= r.volume centroids= v.split input=

I notice that each of them has the following item in their <parameter> tag:

<gisprompt age="old" element="dig" prompt="vector" />

The age and element values differ, but all four have prompt="vector".

Can I use this to identify parameters that take a vector file name?
That is, is the value of <gisprompt prompt="vector"> present for all
commands that should be completed by a vector map name, and is this
value absent from all other parameters?

If not, is their another way to get this information directly from the programs?

Thanks for your help,

Tyler
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Hi Tyler,

···

On Mon, Nov 11, 2013 at 1:44 PM, Maris Nartiss <maris.gis@gmail.com> wrote:

Hello Tyler,
it’s a bit of “black magic” that has historical roots. General
documentation how it should work is here:
http://grass.osgeo.org/programming7/gislib_cmdline_parsing.html#gisprompt_Member

I did some small updates recently [1] but it was more about readability, I don’t know about this much.

The documentation is far from being usable for something different than C. Python command line parsing and XML interface description are not documented.

If you have some ideas or you are willing to document what you are using, we can incorporate this into the manual.

Vaclav

[1] http://lists.osgeo.org/pipermail/grass-dev/2013-October/066084.html

Hope it helps for a start.
Maris.

2013/10/31 Tyler Smith <tyler@plantarum.ca>:

Hello,

(sorry if this gets posted multiple times, I’m having email problems at my end)

I’m developing an Emacs mode for interacting with the GRASS process,
available here:

https://bitbucket.org/tws/grass-mode.el/wiki/Home

One of the features of this mode is offering tab-completion of command
parameters. I use a lookup-table for this, populated by running all
the programs in the bin/ directory with the -interface-description
flag and parsing their output. This works fine for parameters that
have a set list of possible values, like d.vect icon.

However, I also have utility functions that provide completion of
vector and raster map names. I don’t understand the output of
–interface-description well enough to know if there’s a way to
automatically identify parameters that should be completed with a
vector name lookup. For example, all of the following combinations are
completed by a vector map file:

v.convert input= d.vect map= r.volume centroids= v.split input=

I notice that each of them has the following item in their tag:

The age and element values differ, but all four have prompt=“vector”.

Can I use this to identify parameters that take a vector file name?
That is, is the value of present for all
commands that should be completed by a vector map name, and is this
value absent from all other parameters?

If not, is their another way to get this information directly from the programs?

Thanks for your help,

Tyler


grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev


grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Tyler Smith wrote:

However, I also have utility functions that provide completion of
vector and raster map names. I don't understand the output of
--interface-description well enough to know if there's a way to
automatically identify parameters that should be completed with a
vector name lookup. For example, all of the following combinations are
completed by a vector map file:

v.convert input= d.vect map= r.volume centroids= v.split input=

I notice that each of them has the following item in their <parameter> tag:

<gisprompt age="old" element="dig" prompt="vector" />

The age and element values differ, but all four have prompt="vector".

Can I use this to identify parameters that take a vector file name?

You should use the element field to identify options whose arguments
are vector or raster map names.

That is, is the value of <gisprompt prompt="vector"> present for all
commands that should be completed by a vector map name, and is this
value absent from all other parameters?

The value of the "prompt" field is human-readable text (it dates back
to before the GUI, when running a command without options would result
in interactive prompts on the terminal).

The "element" field is machine-readable; it identifies the type of
entity to which the option refers (and, indirectly, the subdirectory
of the mapset directory where the data is stored; see the
etc/element_list file for the mapping between element names and
subdirectories).

If the "age" field is "old", then the file (or directory)
<mapset>/<element>/<name> must exist or an error is generated. If the
"age" field is "new", then <mapset>/<element>/<name> must not exist
unless the --overwrite option is given, or an error is generated.

So the "element" field can be assumed to reliably identify when an
option value must the name of a map (or similar entity, e.g. imagery
group, named region, icon, etc).

--
Glynn Clements <glynn@gclements.plus.com>