# dev generate flag

Generate a flag for an existing command.

## Description for dev generate flag

You must run this command from within a plugin directory, such as the directory created with the "sf dev generate plugin" command.

This command is interactive. It first discovers all the commands currently implemented in the plugin, and asks you which you want to create a new flag for. It then prompts for other flag properties, such as its long name, optional short name, type, whether it's required, and so on. Long flag names must be kebab-case and not camelCase. The command doesn't let you use an existing long or short flag name. When the command completes, the Typescript file for the command is updated with the code for the new flag.

Use the --dry-run flag to review new code for the command file without actually updating it.

## Flags

| Flag Name (Long) | Flag Name (Short) | Description                                                                            |
| ---------------- | ----------------- | -------------------------------------------------------------------------------------- |
| `--dry-run`      | `-d`              | **Type:** Boolean<br><br>Print new flag code instead of adding it to the command file. |
| `--flags-dir`    | N/A               | **Type:** Value<br><br>Import flag values from a directory.                            |

## Examples for dev generate flag

Generate a new flag and update the command file:

```shell
sf dev generate flag
```

Don't actually update the command file, just view the generated code:

```shell
sf dev generate flag --dry-run
```
