Skip to content

Commit 7c8e8d3

Browse files
committed
make directory and decision record template configurable via yaml config file
1 parent e839f18 commit 7c8e8d3

14 files changed

+350
-140
lines changed

adr.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
directory: docs/arch
2+
template:
3+
decision-record: template/skeleton.md

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"require": {
2020
"php": "^7.1.3",
2121
"ext-mbstring": "*",
22-
"symfony/console": "^4.0"
22+
"symfony/console": "^4.0",
23+
"symfony/yaml": "^4.2@dev"
2324
},
2425
"require-dev": {
2526
"phpunit/phpunit": "^7.0.1",

composer.lock

Lines changed: 121 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 6. YAML as configuration file
2+
3+
Date: 2018-06-30
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
In order to use a custom ADR template, it must be possible to configure the path to it. The same template must be used so that all ADR`s are structured in the same way.
12+
13+
## Decision
14+
15+
The template path can be defined via a [YAML](http://yaml.org/) configuration file.
16+
17+
## Consequences
18+
19+
We need to add [symfony/yaml](https://github.com/symfony/yaml) as a dependency to the project.
20+
21+
To have a single place of truth the "directory" option must be removed from all console commands, because the directory can be defined in the configuration file.

src/Command/MakeDecisionCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ADR\Command;
44

5+
use ADR\Filesystem\Config;
56
use Symfony\Component\Console\Command\Command;
67
use Symfony\Component\Console\Input\InputArgument;
78
use Symfony\Component\Console\Input\InputInterface;
@@ -50,11 +51,11 @@ protected function configure()
5051
DecisionContent::STATUS_ACCEPTED
5152
)
5253
->addOption(
53-
'directory',
54+
'config',
5455
null,
5556
InputOption::VALUE_REQUIRED,
56-
'Workspace that store the ADRs',
57-
'docs/arch'
57+
'Config file',
58+
'adr.yml'
5859
);
5960
}
6061

@@ -66,10 +67,11 @@ protected function configure()
6667
*/
6768
protected function execute(InputInterface $input, OutputInterface $output)
6869
{
69-
$workspace = new Workspace($input->getOption('directory'));
70+
$config = new Config($input->getOption('config'));
71+
$workspace = new Workspace($config->directory());
7072
$sequence = new Sequence($workspace);
7173
$content = new DecisionContent($sequence->next(), $input->getArgument('title'), $input->getArgument('status'));
72-
$record = new DecisionRecord($content);
74+
$record = new DecisionRecord($content, $config);
7375

7476
$workspace->add($record);
7577

src/Command/WorkspaceCountCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ADR\Command;
44

5+
use ADR\Filesystem\Config;
56
use Symfony\Component\Console\Command\Command;
67
use Symfony\Component\Console\Input\InputOption;
78
use Symfony\Component\Console\Input\InputInterface;
@@ -26,11 +27,11 @@ protected function configure()
2627
->setDescription('Count the ADRs')
2728
->setHelp('This command allows you count the ADRs')
2829
->addOption(
29-
'directory',
30+
'config',
3031
null,
3132
InputOption::VALUE_REQUIRED,
32-
'Workspace that store the ADRs',
33-
'docs/arch'
33+
'Config file',
34+
'adr.yml'
3435
);
3536
}
3637

@@ -42,8 +43,9 @@ protected function configure()
4243
*/
4344
protected function execute(InputInterface $input, OutputInterface $output)
4445
{
46+
$config = new Config($input->getOption('config'));
4547
$style = new SymfonyStyle($input, $output);
46-
$workspace = new Workspace($input->getOption('directory'));
48+
$workspace = new Workspace($config->directory());
4749

4850
$style->table(['Count'], [[$workspace->count()]]);
4951
}

src/Command/WorkspaceListCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ADR\Command;
44

5+
use ADR\Filesystem\Config;
56
use Symfony\Component\Console\Command\Command;
67
use Symfony\Component\Console\Input\InputOption;
78
use Symfony\Component\Console\Input\InputInterface;
@@ -26,11 +27,11 @@ protected function configure()
2627
->setDescription('List the ADRs')
2728
->setHelp('This command allows you list the ADRs')
2829
->addOption(
29-
'directory',
30+
'config',
3031
null,
3132
InputOption::VALUE_REQUIRED,
32-
'Workspace that store the ADRs',
33-
'docs/arch'
33+
'Config file',
34+
'adr.yml'
3435
);
3536
}
3637

@@ -42,7 +43,8 @@ protected function configure()
4243
*/
4344
protected function execute(InputInterface $input, OutputInterface $output)
4445
{
45-
$workspace = new Workspace($input->getOption('directory'));
46+
$config = new Config($input->getOption('config'));
47+
$workspace = new Workspace($config->directory());
4648

4749
$records = $workspace->records();
4850

0 commit comments

Comments
 (0)