# DiffCommand

> Shows what applying the provider would change in a tracked file, or in every tracked file, as a unified diff.

[API reference](/docs/api/index.md) › [Scaffold](/docs/extensions/scaffold/reference/index.md) › [Console](/docs/extensions/scaffold/reference/console/index.md) › [Command](/docs/extensions/scaffold/reference/console/command/index.md) › DiffCommand

| final class | `PHPForge\Scaffold\Console\Command\DiffCommand` |
| --- | --- |
| Extends | [`AbstractScaffoldCommand`](/docs/extensions/scaffold/reference/console/command/abstractscaffoldcommand/index.md) » `Symfony\Component\Console\Command\Command` |
| Source | [`src/Console/Command/DiffCommand.php`](https://github.com/php-forge/scaffold/blob/main/src/Console/Command/DiffCommand.php#L18) |

Shows what applying the provider would change in a tracked file, or in every tracked file, as a unified diff.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`configure()`](#method-configure) protected | Declares the optional `file` argument and the `--all` and `--exit-code` options. | `DiffCommand` |
| <span id="method-execute"></span>[`execute()`](/docs/extensions/scaffold/reference/console/command/abstractscaffoldcommand/index.md#method-execute) protected final | Validates the input, resolves the project root and runs [`AbstractScaffoldCommand::handle()`](/docs/extensions/scaffold/reference/console/command/abstractscaffoldcommand/index.md#method-handle). | [`AbstractScaffoldCommand`](/docs/extensions/scaffold/reference/console/command/abstractscaffoldcommand/index.md) |
| [`handle()`](#method-handle) protected | Renders the diff of the given file, or of every file with `--all`. | `DiffCommand` |
| [`validate()`](#method-validate) protected | Returns whether exactly one of `file` and `--all` is given. | `DiffCommand` |

## Method details

### configure() <span id="method-configure"></span>

```php
protected function configure(): void
```

Declares the optional `file` argument and the `--all` and `--exit-code` options.

### handle() <span id="method-handle"></span>

```php
protected function handle(Symfony\Component\Console\Input\InputInterface $input, PHPForge\Scaffold\Console\SymfonyOutputWriter $out, string $projectRoot): int
```

Renders the diff of the given file, or of every file with `--all`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$input` | `Symfony\Component\Console\Input\InputInterface` | Input with the `file` argument and the `--all` and `--exit-code` options. |
| `$out` | [`PHPForge\Scaffold\Console\SymfonyOutputWriter`](/docs/extensions/scaffold/reference/console/symfonyoutputwriter/index.md) | Output sink that receives the diff and the error messages. |
| `$projectRoot` | `string` | Absolute path of the project root. |

**Returns**

`int`: Exit code of [`DiffService::run()`](/docs/extensions/scaffold/reference/services/diffservice/index.md#method-run).

### validate() <span id="method-validate"></span>

```php
protected function validate(Symfony\Component\Console\Input\InputInterface $input, PHPForge\Scaffold\Console\SymfonyOutputWriter $out): bool
```

Returns whether exactly one of `file` and `--all` is given.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$input` | `Symfony\Component\Console\Input\InputInterface` | Input with the `file` argument and the `--all` option. |
| `$out` | [`PHPForge\Scaffold\Console\SymfonyOutputWriter`](/docs/extensions/scaffold/reference/console/symfonyoutputwriter/index.md) | Output sink that receives the error message. |

**Returns**

`bool`: `true` when exactly one target is given, `false` otherwise.