recipe-runner/io-module

IO module for Recipe Runner

dev-master / 1.0.x-dev 2019-07-19 14:19 UTC

This package is auto-updated.

Last update: 2024-11-20 02:27:21 UTC


README

Latest Version on Packagist Build Status

Input/output operations such as write or ask for interacting with the user.

Requires

Installation

Create a recipe and add the module to the packages section:

name: "Your recipe"
extra:
  rr:
    packages:
      "recipe-runner/io-module": "1.0.x-dev"

Usage

Method: write

Write a message to the output.

steps:
    - actions:
        - write: "Hi user. Welcome back."

Messages with several lines are allowed:

steps:
    - actions:
        - write: 
            "Hi user"
            "Welcome :)"

Method: ask

Ask a question to the user.

steps:
    - actions:
        - ask: "What's your name?"
          register: "question1"
        - write: "The Response was: '{{question1['response']}}'"

Default value for a question is empty string. Set a custom default value is possible:

ask:
  question: "What's your name?"
  default: "Jack"

Response:

{
  "response": "bla bla"
}

Method ask_yes_no

Ask a yes/no question to the user. Values accepted as response:

  • true: true, "true", "yes", "1", 1
  • false: false, "false", "no", "0", 0

Default value: true.

ask_yes_no: "Are you sure?"

or

ask_yes_no:
  question: "What's your name?"
  default: true

Response:

{
  "response": true
}

For module developers

The preferred installation method is composer:

composer require recipe-runner/io-module

Unit tests

You can run the unit tests with the following command:

$ cd io-module
$ composer test

License

This library is open-sourced software licensed under the MIT license.