[GRASS-dev] doubt with single/double dashed flags from interface description

Hi all,
I have a problem with the handling of flags in the interface description.

Let's take for example pieces of r.watershed,
The help tells me:
[...]
  -a Use positive flow accumulation even for likely underestimates
        See manual for a detailed description of flow accumulation output
--o Allow output files to overwrite existing files
[...]

and the interface description:
[...]

  <flag name="a">
    <label>
      Use positive flow accumulation even for likely underestimates
    </label>
    <description>
      See manual for a detailed description of flow accumulation output
    </description>
  </flag>
  <flag name="overwrite">
    <description>
      Allow output files to overwrite existing files
    </description>
  </flag>
[...]

I can't find a way to understand why the first has one single dash,
while the overwrite flag needs two.
Any hints?

Thanks,
Andrea

My only guess here is that single character flags have a single dash
and multiple character flags a double dash?

Andrea

On Tue, May 24, 2011 at 9:12 PM, andrea antonello
<andrea.antonello@gmail.com> wrote:

Hi all,
I have a problem with the handling of flags in the interface description.

Let's take for example pieces of r.watershed,
The help tells me:
[...]
-a Use positive flow accumulation even for likely underestimates
See manual for a detailed description of flow accumulation output
--o Allow output files to overwrite existing files
[...]

and the interface description:
[...]

   &lt;flag name=&quot;a&quot;&gt;
           &lt;label&gt;
                   Use positive flow accumulation even for likely underestimates
           &lt;/label&gt;
           &lt;description&gt;
                   See manual for a detailed description of flow accumulation output
           &lt;/description&gt;
   &lt;/flag&gt;
   &lt;flag name=&quot;overwrite&quot;&gt;
           &lt;description&gt;
                   Allow output files to overwrite existing files
           &lt;/description&gt;
   &lt;/flag&gt;

[...]

I can't find a way to understand why the first has one single dash,
while the overwrite flag needs two.
Any hints?

Thanks,
Andrea

Hi Andrea,

the double-dash options are generic options available for every module
and not defined by the module: --overwrite, --verbose, --quiet. These
options are used to set global environment variables. Using
r.watershed as example, it could be called through python with e.g.

grass.run_command("r.watershed", elevation = input, accumulation =
output, flags = 'a', overwrite = True, verbose = True)

Some modules, e.g. some of the import modules, have their own
(single-dash) -o flag, where

v.in.ogr -o --o

means "override projection check and overwrite output if existing"

IOW, you could ignore these three double-dash options when handling
flags of interface descriptions because they are available for every
module and not module-specific, if that makes your life easier in
generating wrappers.

HTH,

Markus M

On Tue, May 24, 2011 at 9:23 PM, andrea antonello
<andrea.antonello@gmail.com> wrote:

My only guess here is that single character flags have a single dash
and multiple character flags a double dash?

Andrea

On Tue, May 24, 2011 at 9:12 PM, andrea antonello
<andrea.antonello@gmail.com> wrote:

Hi all,
I have a problem with the handling of flags in the interface description.

Let's take for example pieces of r.watershed,
The help tells me:
[...]
-a Use positive flow accumulation even for likely underestimates
See manual for a detailed description of flow accumulation output
--o Allow output files to overwrite existing files
[...]

and the interface description:
[...]

   &lt;flag name=&quot;a&quot;&gt;
           &lt;label&gt;
                   Use positive flow accumulation even for likely underestimates
           &lt;/label&gt;
           &lt;description&gt;
                   See manual for a detailed description of flow accumulation output
           &lt;/description&gt;
   &lt;/flag&gt;
   &lt;flag name=&quot;overwrite&quot;&gt;
           &lt;description&gt;
                   Allow output files to overwrite existing files
           &lt;/description&gt;
   &lt;/flag&gt;

[...]

I can't find a way to understand why the first has one single dash,
while the overwrite flag needs two.
Any hints?

Thanks,
Andrea

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

Hi Markus,
thanks for the reply and description. Everything is clear now. I will
simply ignore them and add them by default.

Thanks,
Andrea

On Wed, May 25, 2011 at 8:50 AM, Markus Metz
<markus.metz.giswork@googlemail.com> wrote:

Hi Andrea,

the double-dash options are generic options available for every module
and not defined by the module: --overwrite, --verbose, --quiet. These
options are used to set global environment variables. Using
r.watershed as example, it could be called through python with e.g.

grass.run_command("r.watershed", elevation = input, accumulation =
output, flags = 'a', overwrite = True, verbose = True)

Some modules, e.g. some of the import modules, have their own
(single-dash) -o flag, where

v.in.ogr -o --o

means "override projection check and overwrite output if existing"

IOW, you could ignore these three double-dash options when handling
flags of interface descriptions because they are available for every
module and not module-specific, if that makes your life easier in
generating wrappers.

HTH,

Markus M

On Tue, May 24, 2011 at 9:23 PM, andrea antonello
<andrea.antonello@gmail.com> wrote:

My only guess here is that single character flags have a single dash
and multiple character flags a double dash?

Andrea

On Tue, May 24, 2011 at 9:12 PM, andrea antonello
<andrea.antonello@gmail.com> wrote:

Hi all,
I have a problem with the handling of flags in the interface description.

Let's take for example pieces of r.watershed,
The help tells me:
[...]
-a Use positive flow accumulation even for likely underestimates
See manual for a detailed description of flow accumulation output
--o Allow output files to overwrite existing files
[...]

and the interface description:
[...]

   &lt;flag name=&quot;a&quot;&gt;
           &lt;label&gt;
                   Use positive flow accumulation even for likely underestimates
           &lt;/label&gt;
           &lt;description&gt;
                   See manual for a detailed description of flow accumulation output
           &lt;/description&gt;
   &lt;/flag&gt;
   &lt;flag name=&quot;overwrite&quot;&gt;
           &lt;description&gt;
                   Allow output files to overwrite existing files
           &lt;/description&gt;
   &lt;/flag&gt;

[...]

I can't find a way to understand why the first has one single dash,
while the overwrite flag needs two.
Any hints?

Thanks,
Andrea

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

Markus Metz wrote:

the double-dash options are generic options available for every module
and not defined by the module: --overwrite, --verbose, --quiet.

IOW, you could ignore these three double-dash options when handling
flags of interface descriptions because they are available for every
module and not module-specific

One caveat: --overwrite is only listed as an available flag for
modules which have at least one option with "new" in the gisprompt
field or which explicitly set the "overwrite" field in the GModule
structure (there's no equivalent for scripts).

All modules accept --overwrite, regardless of whether it's listed. If
there are no "new" options, the parser doesn't perform overwrite
checks, but it will still set GRASS_OVERWRITE=1.

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

On Wed, May 25, 2011 at 1:31 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Markus Metz wrote:

the double-dash options are generic options available for every module
and not defined by the module: --overwrite, --verbose, --quiet.

IOW, you could ignore these three double-dash options when handling
flags of interface descriptions because they are available for every
module and not module-specific

One caveat: --overwrite is only listed as an available flag for
modules which have at least one option with "new" in the gisprompt
field or which explicitly set the "overwrite" field in the GModule
structure (there's no equivalent for scripts).

All modules accept --overwrite, regardless of whether it's listed. If
there are no "new" options, the parser doesn't perform overwrite
checks, but it will still set GRASS_OVERWRITE=1.

Useful for e.g. g.copy rast=rast,myrast --o on the command line (in
the wxGUI there is no overwrite option for g.copy)

Markus Metz wrote:

> All modules accept --overwrite, regardless of whether it's listed. If
> there are no "new" options, the parser doesn't perform overwrite
> checks, but it will still set GRASS_OVERWRITE=1.

Useful for e.g. g.copy rast=rast,myrast --o on the command line (in
the wxGUI there is no overwrite option for g.copy)

Each option has a single gisprompt field, even if it takes multiple
values of different types (via the key_desc field).

It isn't possible for an option to be both "old" and "new". If it was
declared "new", you would be forced to use --overwrite to avoid errors
due to the source maps existing.

g.copy's options are all declared "old", which is mostly harmless as
G_parser() doesn't check that the maps actually exist.

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