pelican-panel-mirror/app/Console/Commands/Node/NodeConfigurationCommand.php
MartinOscar 1f6b659546
Fix Translations (#994)
* Fix copy paste AllocationsRelationManager

* We shouldn't let the user know if the user is correct but the password isn't

* Add missing `trans()` `EditServer`

* Add missing `trans()` User `ServersRelationManager`

* Replace every `__()` with `trans()` helper

* Fix `exceptions` `User` Model

* Replace `Translator->get()` with `trans()` helper

* Revert "We shouldn't let the user know if the user is correct but the password isn't"

This reverts commit e156ee4b38e9e969662a532648c78fdc1e9b0166.
that's stock laravel, therefore it needs to stay
2025-02-11 22:16:48 +01:00

45 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands\Node;
use App\Models\Node;
use Illuminate\Console\Command;
class NodeConfigurationCommand extends Command
{
protected $signature = 'p:node:configuration
{node : The ID or UUID of the node to return the configuration for.}
{--format=yaml : The output format. Options are "yaml" and "json".}';
protected $description = 'Displays the configuration for the specified node.';
public function handle(): int
{
$column = ctype_digit((string) $this->argument('node')) ? 'id' : 'uuid';
/** @var \App\Models\Node $node */
$node = Node::query()->where($column, $this->argument('node'))->firstOr(function () {
$this->error(trans('commands.node_config.error_not_exist'));
exit(1);
});
$format = $this->option('format');
if (!in_array($format, ['yaml', 'yml', 'json'])) {
$this->error(trans('commands.node_config.error_invalid_format'));
return 1;
}
if ($format === 'json') {
$this->output->write($node->getJsonConfiguration(true));
} else {
$this->output->write($node->getYamlConfiguration());
}
$this->output->newLine();
return 0;
}
}