Skip to content

Commit 8a5715c

Browse files
committed
switching to dic based approach
1 parent 7956ed1 commit 8a5715c

18 files changed

+1096
-175
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# CLI Note
2+
3+
CLI Note is an experiment to use a console application as a slide deck.
4+
5+
## Usage
6+
7+
Use [jaem3l/cli-note-presentation](https://github.com/jaem3l/cli-note-presentation) as skeleton for your presentation.
8+
9+
## Example
10+
11+
To execute a simple example you can just clone this repository:
12+
13+
```bash
14+
$ git clone [email protected]:jaem3l/cli-note.git
15+
$ cd cli-note
16+
$ composer install
17+
$ ./cli-note
18+
```
19+
20+
## Controls
21+
22+
**Start at specific slide**
23+
24+
```bash
25+
$ ./cli-note --start-at=10
26+
$ ./cli-note -s 10
27+
```
28+
29+
**While presentation**
30+
31+
* `p`, `prev` or `previous`: render previous slide
32+
* `c` or `current`: render current slide again
33+
* `n` or `next`: render next slide
34+
* `f` or `first`: render first slide
35+
* `l` or `last`: render last slide
36+
37+
## Slides
38+
39+
CLI Note ships with seven different built-in slides
40+
41+
* CanvasSlide - an abstract slide to render various canvas elements based on [chr-hertel/console-canvas](https://github.com/chr-hertel/console-canvas)
42+
* CodeSlide - to print highlighted code snippets
43+
* ImageSlide - to print images
44+
* ListSlide - to print a list with a headline
45+
* ProcessSlide - to print the output of a child process
46+
* TextSlide - to print a text file with formatting possible
47+
* TitleSlide - to print a title and an optional subtitle
48+
49+
## Disclaimer
50+
51+
This is just a project to demonstrate the capabilities of Symfony Console Component for SymfonyWorld 2020.
52+
Use this on your own risk and do not expect this to be actively maintained.

cli-note

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use jæm3l\CliNote\Slide;
5+
use jæm3l\CliNote\DependencyInjection\SlidePass;
6+
use Symfony\Component\Config\FileLocator;
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\ConsoleEvents;
9+
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
10+
use Symfony\Component\DependencyInjection\ContainerBuilder;
11+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
12+
use Symfony\Component\ErrorHandler\ErrorHandler;
13+
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
14+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15+
16+
require 'vendor/autoload.php';
17+
18+
ErrorHandler::register();
19+
$container = new ContainerBuilder();
20+
21+
// Configure console.
22+
$container->addCompilerPass(new AddConsoleCommandPass());
23+
$container->registerForAutoconfiguration(Command::class)
24+
->addTag('console.command');
25+
26+
// Configure event dispatcher.
27+
$container->setParameter('event_dispatcher.event_aliases', ConsoleEvents::ALIASES);
28+
$container->addCompilerPass(new RegisterListenersPass());
29+
$container->registerForAutoconfiguration(EventSubscriberInterface::class)
30+
->addTag('kernel.event_subscriber');
31+
32+
// Configure slides.
33+
$container->addCompilerPass(new SlidePass());
34+
$container->registerForAutoconfiguration(Slide::class)
35+
->addTag('cli_note.slide');
36+
37+
// Load slides.yaml.
38+
(new YamlFileLoader($container, new FileLocator(__DIR__.'/config')))->load('services.yaml');
39+
(new YamlFileLoader($container, new FileLocator(getcwd())))->load('slides.yaml');
40+
41+
$container->setParameter('base_path', getcwd());
42+
$container->compile();
43+
44+
$container
45+
->get('CliNote')
46+
->run();

composer.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@
1515
"stoffel/console-canvas": "^0.1",
1616
"stoffel/console-sourcecode": "^0.1",
1717
"symfony/console": "^5.2",
18-
"symfony/process": "^5.2"
18+
"symfony/process": "^5.2",
19+
"symfony/event-dispatcher": "^5.2",
20+
"symfony/error-handler": "^5.2",
21+
"symfony/filesystem": "^5.2",
22+
"symfony/dependency-injection": "^5.2",
23+
"symfony/config": "^5.2",
24+
"symfony/yaml": "^5.2"
1925
},
2026
"autoload": {
21-
"psr-4": {
27+
"psr-4": {
2228
"jæm3l\\CliNote\\": "src/"
2329
}
24-
}
30+
},
31+
"bin": "cli-note"
2532
}

0 commit comments

Comments
 (0)