Skip to content

Commit 0319301

Browse files
committed
[dotenv:debug] Add command.
1 parent 48bb017 commit 0319301

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drupal/console-dotenv",
3-
"description": "Drupal Console dotenv",
3+
"description": "Drupal Console Dotenv",
44
"type": "drupal-console-library",
55
"license": "GPL-2.0+",
66
"authors": [

console.services.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ services:
44
arguments: ['@app.root', '@?console.root']
55
tags:
66
- { name: drupal.command, bootstrap: uninstall }
7+
console.dotenv_debug:
8+
class: \Drupal\Console\Dotenv\Command\DebugCommand
9+
arguments: ['@app.root', '@?console.root']
10+
tags:
11+
- { name: drupal.command, bootstrap: uninstall }

src/Command/DebugCommand.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace Drupal\Console\Dotenv\Command;
4+
5+
use Symfony\Component\Console\Input\InputInterface;
6+
use Symfony\Component\Console\Output\OutputInterface;
7+
use Symfony\Component\Console\Command\Command;
8+
use Drupal\Console\Core\Command\Shared\CommandTrait;
9+
use Drupal\Console\Core\Style\DrupalStyle;
10+
use Symfony\Component\Filesystem\Filesystem;
11+
use Drupal\Component\Utility\Crypt;
12+
use Webmozart\PathUtil\Path;
13+
14+
/**
15+
* Class ExampleOneCommand
16+
*
17+
* @package Drupal\Console\Dotenv\Command
18+
*/
19+
class DebugCommand extends Command
20+
{
21+
use CommandTrait;
22+
23+
/**
24+
* @var string
25+
*/
26+
protected $appRoot;
27+
28+
/**
29+
* @var string
30+
*/
31+
protected $consoleRoot;
32+
33+
/**
34+
* InitCommand constructor.
35+
*
36+
* @param string $appRoot
37+
* @param string $consoleRoot
38+
*/
39+
public function __construct(
40+
$appRoot,
41+
$consoleRoot = null
42+
)
43+
{
44+
$this->appRoot = $appRoot;
45+
$this->consoleRoot = $consoleRoot?$consoleRoot:$appRoot;
46+
parent::__construct();
47+
}
48+
49+
protected function configure()
50+
{
51+
$this->setName('dotenv:debug')
52+
->setDescription('Debug Dotenv debug values.');
53+
}
54+
55+
/**
56+
* {@inheritdoc}
57+
*/
58+
protected function execute(InputInterface $input, OutputInterface $output)
59+
{
60+
$io = new DrupalStyle($input, $output);
61+
$this->copyFiles($io);
62+
}
63+
64+
private function debugFile(DrupalStyle $io) {
65+
$fs = new Filesystem();
66+
$envFile = $this->consoleRoot . '/.env';
67+
if (!$fs->exists($envFile)) {
68+
$io->warning('File '. $envFile . ' not found.');
69+
70+
return 1;
71+
}
72+
73+
$fileContent = file_get_contents($envFile);
74+
$io->writeln($fileContent);
75+
}
76+
}

src/Command/InitCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(
4949
protected function configure()
5050
{
5151
$this->setName('dotenv:init')
52-
->setDescription('Drupal Console dotenv.');
52+
->setDescription('Drupal Console Dotenv initializer.');
5353
}
5454

5555
/**

0 commit comments

Comments
 (0)