node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »


cli-presentation Build status

Give presentations from your terminal

This was built from the library created in Develop Faster.

$ cli-presentation status
* 0 title.js
  1 overview.js
  2 create-a-repo.js
  3 write-some-code-server.js
  4 compile-assets.js
  5 write-some-code-browser.js
  6 commit.js
  7 write-some-tests.js
  8 release.js
  9 reflection.js
  10 title.js

Getting Started

Install the module with: npm install cli-presentation -g

Set up a cli-presentation.yml config to read from:

cat > cli-presentation.yml <<EOF
  - hello.js
  - world.js
cat > hello.js <<EOF
module.exports = function () {
  // TODO: If a string is returned, it will be logged.
  // Otherwise, it is assumed the slide logged its own content.
  return 'Hello';
cat > world.js <<EOF
module.exports = function () {
  return 'World!';

In a terminal:

# Outputs: Hello
cli-presentation next
# Outputs: World!

Executable interface

cli-presentation installs a CLI executable cli-presentation. It provides the following commands:

$ cli-presentation --help
  Usage: cli-presentation [options] [command]
    slide <slide>          Jump to a specific slide
    first                  Go back to the beginning
    last                   Jump to the final slide
    next                   Move following by one slide
    previous               Move back by one slide
    back                   Alias for previous
    status                 Get overview of slides
    -h, --help             output usage information
    -c, --config <config>  Path to configuration file (accepts .js, .json, .yml)

Slide format

Slides are loaded via require and expected to return a Function as their module.exports.

When a slide is presented, its module.exports is run. If the module.exports returns a String, the output will be processed via console.log.

Example: Outputting from the slide

// Inside of 1.js 
module.exports = function () {
  console.log('Hello World!');
// From the command line 
$ cli-presentation 1
Hello World!

Example: Returning content from the slide

// Inside of 2.js 
module.exports = function () {
  return 'Nyan cat!';
// From the command line 
$ cli-presentation 2
Nyan cat!


cli-presentation exposes a constructor CliPresentation as its module.exports.

new CliPresentation(options)

Constructor for a new CLI presentation

  • options String|Object - If options is a string, it is assumed to be a path and resolved via require
    • cwd String - Directory to locate slides and database. By default, this is process.cwd()
    • db String - Path to database. If relative, it will resolve from cwd

CliPresentation.goToSlide(slide, cb)

Navigate and output the content of a slide

  • slide Number - Index of slide to navigate to (zero based)
  • cb Function - Optional callback function with signature function (err) {}. If not provided and an error is encountered, it will be thrown.


Output the current slide


Output the beginning slide


Output the final slide


Output the following slide


Output the previous slide


Output the presentation progress

$ cli-presentation status  # on second slide
  0 title.js
* 1 overview.js
  2 create-a-repo.js


Return a commander instance with the bindings of the CLI interface.

  • defaults Object - Override default CLI values
    • config String - Default path to presentation configuration. By default, this is cli-presentation

By using this, you can define your custom alias and additional commands

// Mimic behavior from `cli-presentation` 
var yaml = require('js-yaml'); // Enables loading of .yml files 
  // OPTIONAL: Add `--version` from `package.json` 

This is an example of using defaults to override config

var CliPresentation = require('cli-presentation');
  config: 'presentation/config'


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.


Support this project and others by twolfson via gittip.

Support via Gittip


As of Dec 06 2013, Todd Wolfson has released this repository and its contents to the public domain.

It has been released under the UNLICENSE.