https://github.com/zicht/z-plugin-interact
Utility - Z plugin 'interact' - Simple user interaction utilities
https://github.com/zicht/z-plugin-interact
packagist
Last synced: about 1 year ago
JSON representation
Utility - Z plugin 'interact' - Simple user interaction utilities
- Host: GitHub
- URL: https://github.com/zicht/z-plugin-interact
- Owner: zicht
- License: mit
- Created: 2016-10-18T14:10:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-08T19:20:15.000Z (over 4 years ago)
- Last Synced: 2025-01-23T14:55:54.356Z (over 1 year ago)
- Topics: packagist
- Language: PHP
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# z plugin for user interaction
This plugin provides a few user interaction utilities implemented using the 'dialog helper' from Symfony.
## Examples:
### Ask a user for confirmation
```yml
plugins: ['interact']
tasks:
test:
- @(if confirm("Are you sure?")) echo "OK, I will..."
```
### Ask a user to choose between a few options
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:
```yml
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:
```
$ 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"' )
```
### Ask a user for text input
```yml
plugins: ['interact']
tasks:
test:
set:
name: ask("What is your name?", USER)
do: echo "Hello $(name), my name is `uname`"
```
Running this:
```
$ z test
What is your name? [gerard]:
Hello gerard, my name is Linux
```
# Maintainer(s)
* Jochem Klaver