diff --git a/mapg b/mapg
index 6409a95..8acfda2 100755
--- a/mapg
+++ b/mapg
@@ -7,5 +7,6 @@ $app = new Symfony\Component\Console\Application('MapGuesser Console', '');
$app->add(new MapGuesser\Cli\DatabaseMigration());
$app->add(new MapGuesser\Cli\AddUserCommand());
+$app->add(new MapGuesser\Cli\LinkViewCommand());
$app->run();
diff --git a/src/Cli/LinkViewCommand.php b/src/Cli/LinkViewCommand.php
new file mode 100644
index 0000000..cccd74e
--- /dev/null
+++ b/src/Cli/LinkViewCommand.php
@@ -0,0 +1,69 @@
+setName('view:link')
+ ->setDescription('Linking of views.')
+ ->addArgument('view', InputArgument::OPTIONAL, 'View file to be linked.');
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $views = [];
+
+ $view = $input->getArgument('view');
+
+ if ($view !== null) {
+ $views[] = $view;
+ } else {
+ $folder = ROOT . '/views';
+ $folderLength = strlen($folder) + 1;
+
+ $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folder, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
+
+ foreach ($iterator as $file) {
+ if ($file->isDir() || $file->getExtension() !== 'php') {
+ continue;
+ }
+
+ $view = substr($file->getPath(), $folderLength) . '/' . $file->getBasename('.php');
+
+ if (strpos($view, 'templates') === 0) {
+ continue;
+ }
+
+ $views[] = $view;
+ }
+ }
+
+ try {
+ foreach ($views as $view) {
+ $generator = new Linker($view);
+ $generator->generate();
+ }
+ } catch (\Exception $e) {
+ $output->writeln('Linking view(s) failed!');
+ $output->writeln('');
+
+ $output->writeln((string) $e);
+ $output->writeln('');
+
+ return 1;
+ }
+
+ $output->writeln('View(s) successfully linked!');
+
+ return 0;
+ }
+}