All Projects â†’ saschagrunert â†’ Demo

saschagrunert / Demo

Licence: mit
A framework for performing live pre-recorded command line demos in the wild 📼

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Demo

Cointop
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
Stars: ✭ 2,912 (+1526.82%)
Mutual labels:  cli, command-line
Handlr
A better xdg-utils
Stars: ✭ 151 (-15.64%)
Mutual labels:  cli, command-line
Swift For Scripting
📋A hand-curated collection of useful and informative Swift Scripting materials.
Stars: ✭ 142 (-20.67%)
Mutual labels:  cli, command-line
Git Tidy
Tidy up stale git branches.
Stars: ✭ 137 (-23.46%)
Mutual labels:  cli, command-line
Magicli
Automagically generates command-line interfaces (CLI) for any module. Expected options and help sections are created automatically based on parameters names, with support to async.
Stars: ✭ 178 (-0.56%)
Mutual labels:  cli, command-line
Brotab
Control your browser's tabs from the command line
Stars: ✭ 137 (-23.46%)
Mutual labels:  cli, command-line
Deno Cliffy
Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Stars: ✭ 149 (-16.76%)
Mutual labels:  cli, command-line
Grmon
Command line monitoring for goroutines
Stars: ✭ 1,703 (+851.4%)
Mutual labels:  cli, command-line
Qoa
Minimal interactive command-line prompts
Stars: ✭ 2,007 (+1021.23%)
Mutual labels:  cli, command-line
Commander
🚀The framework to write type-safe and structured command line program easily in Swift.
Stars: ✭ 170 (-5.03%)
Mutual labels:  cli, command-line
Entrypoint
Composable CLI Argument Parser for all modern .Net platforms.
Stars: ✭ 136 (-24.02%)
Mutual labels:  cli, command-line
Tably
Python command-line script for converting .csv data to LaTeX tables
Stars: ✭ 173 (-3.35%)
Mutual labels:  cli, command-line
The Way
A command line code snippets manager
Stars: ✭ 132 (-26.26%)
Mutual labels:  cli, command-line
Node Promptly
Simple command line prompting utility for nodejs
Stars: ✭ 140 (-21.79%)
Mutual labels:  cli, command-line
Check It Out
A command line interface for Git Checkout. See branches available for checkout.
Stars: ✭ 127 (-29.05%)
Mutual labels:  cli, command-line
Athenacli
AthenaCLI is a CLI tool for AWS Athena service that can do auto-completion and syntax highlighting.
Stars: ✭ 151 (-15.64%)
Mutual labels:  cli, command-line
Dynein
DynamoDB CLI written in Rust.
Stars: ✭ 126 (-29.61%)
Mutual labels:  cli, command-line
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (-29.61%)
Mutual labels:  cli, command-line
Proji
A powerful cross-platform CLI project templating tool.
Stars: ✭ 156 (-12.85%)
Mutual labels:  cli, command-line
Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (-3.35%)
Mutual labels:  cli, command-line

demo

CircleCI codecov docs

demo

A framework for performing live pre-recorded command line demos in the wild 📼

Recording command line demos can be a difficult topic these days. Doing a video record has the drawback of lacking flexibility and reduced interactivity during the demo. Typing everything by our own is error prone and distracts the audience from the actual topic we want to show them. So we need something in between, which is easy to use…

This framework should solve the issue by provided interactive demos from your command line!

Usage

Every demo is a stand-alone command line application which consist of multiple runs. For example, if we create a demo like this:

package main

import (
	demo "github.com/saschagrunert/demo"
)

func main() {
	demo.New().Run()
}

Then this demo already contains features like auto-play. We can verify this checking the help output of the executable:

NAME:
   main - A new cli application

USAGE:
   main [global options] command [command options] [arguments...]

VERSION:
   0.0.0

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --all, -l                     run all demos (default: false)
   --auto, -a                    run the demo in automatic mode, where every step gets executed automatically (default: false)
   --auto-timeout auto, -t auto  the timeout to be waited when auto is enabled (default: 3s)
   --continuously, -c            run the demos continuously without any end (default: false)
   --immediate, -i               immediately output without the typewriter animation (default: false)
   --hide-descriptions, -d       hide descriptions between the steps (default: false)
   --skip-steps value, -s value  skip the amount of initial steps within the demo (default: 0)
   --help, -h                    show help (default: false)
   --version, -v                 print the version (default: false)

The application is based on the urfave/cli framework, which means that we have every possibility to change the app before actually running it.

// Create a new demo CLI application
d := demo.New()

// A demo is an usual urfave/cli application, which means
// that we can set its properties as expected:
d.Name = "A demo of something"
d.Usage = "Learn how this framework is being used"
d.HideVersion = true

Creating runs inside demos

To have something to show, we need to create a run and add it to the demo. This can be done by using the demo.Add() method:

func main() {
	// Create a new demo CLI application
	d := demo.New()

	// Register the demo run
	d.Add(example(), "demo-0", "just an example demo run")

	// Run the application, which registers all signal handlers and waits for
	// the app to exit
	d.Run()
}

// example is the single demo run for this application
func example() *Run {
	// A new run contains a title and an optional description
	r := NewRun(
		"Demo Title",
		"Some additional",
		"multi-line description",
		"is possible as well!",
	)

	// A single step can consist of a description and a command to be executed
	r.Step(S(
		"This is a possible",
		"description of the following command",
		"to be executed",
	), S(
		"echo hello world",
	))

	// Commands do not need to have a description, so we could set it to `nil`
	r.Step(nil, S(
		"echo without description",
		"but this can be executed in",
		"multiple lines as well",
	))

	// It is also not needed at all to provide a command
	r.Step(S(
		"Just a description without a command",
	), nil)

	return r
}

The example() function creates a new demo run, which itself contains of multiple steps. These steps are executed in order, can contain a description and a command to be executed. Wrapping commands in multiple lines will automatically create a line break in the command line.

Setup and Cleanup functions

It is also possible to do something before or after each run. For this the setup and cleanup functions can be set to the demo:

func main() {
	// Create a new demo CLI application
	d := demo.New()

	// Be able to run a Setup/Cleanup function before/after each run
	d.Setup(setup)
	d.Cleanup(cleanup)
}

// setup will run before every demo
func setup(ctx *cli.Context) error {
	// Ensure can be used for easy sequential command execution
	return Ensure(
		"echo 'Doing first setup…'",
		"echo 'Doing second setup…'",
		"echo 'Doing third setup…'",
	)
}

// setup will run after every demo
func cleanup(ctx *cli.Context) error {
	return Ensure("echo 'Doing cleanup…'")
}

Contributing

You want to contribute to this project? Wow, thanks! So please just fork it and send me a pull request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].