Skip to content

Commit

Permalink
switching to dic based approach
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-hertel committed Dec 1, 2020
1 parent 7956ed1 commit 8a5715c
Show file tree
Hide file tree
Showing 18 changed files with 1,096 additions and 175 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# CLI Note

CLI Note is an experiment to use a console application as a slide deck.

## Usage

Use [jaem3l/cli-note-presentation](https://github.com/jaem3l/cli-note-presentation) as skeleton for your presentation.

## Example

To execute a simple example you can just clone this repository:

```bash
$ git clone git@github.com:jaem3l/cli-note.git
$ cd cli-note
$ composer install
$ ./cli-note
```

## Controls

**Start at specific slide**

```bash
$ ./cli-note --start-at=10
$ ./cli-note -s 10
```

**While presentation**

* `p`, `prev` or `previous`: render previous slide
* `c` or `current`: render current slide again
* `n` or `next`: render next slide
* `f` or `first`: render first slide
* `l` or `last`: render last slide

## Slides

CLI Note ships with seven different built-in slides

* CanvasSlide - an abstract slide to render various canvas elements based on [chr-hertel/console-canvas](https://github.com/chr-hertel/console-canvas)
* CodeSlide - to print highlighted code snippets
* ImageSlide - to print images
* ListSlide - to print a list with a headline
* ProcessSlide - to print the output of a child process
* TextSlide - to print a text file with formatting possible
* TitleSlide - to print a title and an optional subtitle

## Disclaimer

This is just a project to demonstrate the capabilities of Symfony Console Component for SymfonyWorld 2020.
Use this on your own risk and do not expect this to be actively maintained.
46 changes: 46 additions & 0 deletions cli-note
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env php
<?php

use jæm3l\CliNote\Slide;
use jæm3l\CliNote\DependencyInjection\SlidePass;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\ErrorHandler\ErrorHandler;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

require 'vendor/autoload.php';

ErrorHandler::register();
$container = new ContainerBuilder();

// Configure console.
$container->addCompilerPass(new AddConsoleCommandPass());
$container->registerForAutoconfiguration(Command::class)
->addTag('console.command');

// Configure event dispatcher.
$container->setParameter('event_dispatcher.event_aliases', ConsoleEvents::ALIASES);
$container->addCompilerPass(new RegisterListenersPass());
$container->registerForAutoconfiguration(EventSubscriberInterface::class)
->addTag('kernel.event_subscriber');

// Configure slides.
$container->addCompilerPass(new SlidePass());
$container->registerForAutoconfiguration(Slide::class)
->addTag('cli_note.slide');

// Load slides.yaml.
(new YamlFileLoader($container, new FileLocator(__DIR__.'/config')))->load('services.yaml');
(new YamlFileLoader($container, new FileLocator(getcwd())))->load('slides.yaml');

$container->setParameter('base_path', getcwd());
$container->compile();

$container
->get('CliNote')
->run();
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
"stoffel/console-canvas": "^0.1",
"stoffel/console-sourcecode": "^0.1",
"symfony/console": "^5.2",
"symfony/process": "^5.2"
"symfony/process": "^5.2",
"symfony/event-dispatcher": "^5.2",
"symfony/error-handler": "^5.2",
"symfony/filesystem": "^5.2",
"symfony/dependency-injection": "^5.2",
"symfony/config": "^5.2",
"symfony/yaml": "^5.2"
},
"autoload": {
"psr-4": {
"psr-4": {
"jæm3l\\CliNote\\": "src/"
}
}
},
"bin": "cli-note"
}
Loading

0 comments on commit 8a5715c

Please # to comment.