---
name: "MooseX::App::Meta::Role::Attribute::Option"
section: "3pm"
platform: "linux"
package: "libmoosex-app-perl"
version: "1.43-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/MooseX::App::Meta::Role::Attribute::Option"
---

# MooseX::App::Meta::Role::Attribute::Option(3pm)

Meta attribute role for options

## NAME

MooseX::App::Meta::Role::Attribute::Option - Meta attribute role for options

## DESCRIPTION

This meta attribute role will automatically be applied to all attributes that should be used as options.

## ACCESSORS

In your app and command classes you can use the following attributes in option or parameter definitions.

```
 option 'myoption' => (
     is                 => 'rw',
     isa                => 'ArrayRef[Str]',
     documentation      => 'My special option',
     cmd_flag           => 'myopt',
     cmd_aliases        => [qw(mopt localopt)],
     cmd_tags           => [qw(Important!)],
     cmd_env            => 'MY_OPTION',
     cmd_position       => 1,
     cmd_split          => qr/,/,
     cmd_negate         => 'notoption'
 );
```

### cmd\_flag

Use this name instead of the attribute name as the option name

### cmd\_type

Option to mark if this attribute should be used as an option or parameter value.

Allowed values are:

- •

  option - Command line option

- •

  proto - Command line option that should be processed prior to other options (eg. a config-file option that sets other attribues) Usually only used for plugin developmemt

- •

  parameter - Positional parameter command line value

### cmd\_env

Environment variable name (only uppercase letters, numeric and underscores allowed). If variable was not specified otherwise the value will be taken from `%ENV`.

### cmd\_aliases

Arrayref of alternative option names

### cmd\_tags

Extra option tags displayed in the usage information (in brackets)

### cmd\_position

Override the order of the parameters in the usage message.

### cmd\_split

Splits multiple values at the given separator string or regular expression. Only works in conjunction with an 'ArrayRef\[\*\]' type constraint. ie. '--myattr value1,value2' with cmd\_split set to ',' would produce an arrayref with to elements.

### cmd\_count

Similar to the Getopt::Long '+' modifier, cmd\_count turns the attribute into a counter. Every occurrence of the attribute in `@ARGV` (without any value) would increment the resulting value by one

### cmd\_negate

Sets names for the negated variant of a boolean field. Only works in conjunction with a 'Bool' type constraint.

## METHODS

These methods are only of interest to plugin authors.

### cmd\_check

Runs sanity checks on options and parameters. Will usually only be executed if either HARNESS\_ACTIVE or APP\_DEVELOPER environment are set.

### cmd\_name\_possible

```
 my @names = $attribute->cmd_name_possible();
```

Returns a list of all possible option names.

### cmd\_name\_list

```
 my @names = $attribute->cmd_name_list();
```

Similar to cmd\_name\_possible this method returns a list of option names, except for names set via cmd\_negate.

### cmd\_name\_primary

```
 my $name = $attribute->cmd_name_primary();
```

Returns the primary option name

### cmd\_usage\_name

```
 my $name = $attribute->cmd_usage_name();
```

Returns the name as used by the usage text

### cmd\_usage\_description

```
 my $name = $attribute->cmd_usage_description();
```

Returns the description as used by the usage text

### cmd\_tags\_list

```
 my @tags = $attribute->cmd_tags_list();
```

Returns a list of tags

### cmd\_type\_constraint\_check

```
 $attribute->cmd_type_constraint_check($value)
```

Checks the type constraint. Returns an error message if the check fails

### cmd\_type\_constraint\_description

```
 $attribute->cmd_type_constraint_description($type_constraint,$singular)
```

Creates a description of the selected type constraint.
