2017 © Pedro Peláez
 

project icm

Interactive Command line Markup

image

slk/icm

Interactive Command line Markup

  • Wednesday, August 12, 2015
  • by slaff
  • Repository
  • 1 Watchers
  • 2 Stars
  • 4,827 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Interactive Command line Markup(ICM), (*1)

ICM is created to allow you easily create intereactive tutorials for your command line program similar to the interactive tutorials of Redis (http://try.redis.io) or Docker (https://www.docker.io/gettingstarted/)., (*2)

Installation

Add the following line in in require compose.json section:, (*3)

"slk/icm" : "dev-master", (*4)

After that in your PHP application you can use the Slk\View\ICMRenderer., (*5)

Markup Langage

Prompt ~~~~~~ To prompt the user input you can add in the beginning of a line the following, (*6)

_, (*7)

To prompt for user output and show also the name of the command line program use:, (*8)

$_, (*9)

The sequence below can be used to check against the user input against expected value:, (*10)

$_ ==--help, (*11)

That above two lines will create a prompt with the name of the current program and will expect from the user to enter --help, (*12)

You can also use also regular experession for input matching, (*13)

$_ ==/\s--help\s/, (*14)

The command above will check if the user entered --help with or without trailing spaces., (*15)

If the expected input from the user is difficult for him to guess you can add an example., (*16)

$_ ==/\scommand\s+--help\s/ ===command --help, (*17)

And finally if you want to save the user input you can store it in a variable with a name, (*18)

$_ ==/\scommand\s+--help\s/ ===command --help => input, (*19)

The above three lines will ask the user for an input, he has to answer with "command --help" or will be shown the example at the end and the input of the user will be saved in a variable with the name input., (*20)

Command exection ~~~~~~~~ To pass arguments to the current console line program and execute them you can use the following syntax:, (*21)

$_ xyz, (*22)

This will execute the in a separate shell " xyz". The result will be save in a variable with a name "result"., (*23)

Variables ~~~~~ Variables are describe in the same way that you do in PHP. There is one pre-defined variable $script that contains the full name of the command line application that is currently executed., (*24)

After command execution with $_ the result is saved in $result. The input from a promt can be saved in a named variable that can be used later on., (*25)

$_ ==/\scommand\s+--help\s/ ===command --help => input, (*26)

In the example above after these four lines are executed you can get the info by reading $input., (*27)

Page breaks ~~~~~~~~~~~, (*28)

If you have a line starting with three or more dashes (-) then this will ask the user to press enter to continue. And if you have three or more > symbols this will ask the user to press enter in order to go on the next page. Going on the next page in a command line context means to clear the currect screen., (*29)

The Versions

12/08 2015

dev-master

9999999-dev https://github.com/slaff/slk-icm

Interactive Command line Markup

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

console zf2 command line markup