26/01
2017
Wallogit.com
2017 © Pedro Peláez
Console interaction plugin for Z
This plugin provides a few user interaction utilities implemented using the 'dialog helper' from Symfony., (*1)
plugins: ['interact']
tasks:
test:
- @(if confirm("Are you sure?")) echo "OK, I will..."
It's very easy to supply defaults with Z, which will ask the user
if it wasn't supplied on the command line. See this example which
uses env and interact together:, (*2)
plugins: ['interact', 'env']
envs:
production:
ssh: user@production
testing:
ssh: user@production
tasks:
ssh:
args:
target_env: ? choose("Where do you want to go?", keys envs)
do: @env.ssh
This will result in a list of options being displayed:, (*3)
$ z --explain ssh [0] production [1] testing Where do you want to go?: 1 NOTICE: interactive shell: ( /bin/bash -c 'ssh -tq user@testing "cd ; bash --login"' )
plugins: ['interact']
tasks:
test:
set:
name: ask("What is your name?", USER)
do: echo "Hello $(name), my name is `uname`"
Running this:, (*4)
$ z test What is your name? [gerard]: Hello gerard, my name is Linux