zicht / z-plugin-interact
Z 控制台交互插件
1.0.1
2022-02-08 19:19 UTC
Requires
- symfony/console: >=2.8
This package is auto-updated.
Last update: 2024-09-09 00:48:29 UTC
README
此插件提供了一些使用 Symfony 的 'dialog helper' 实现的用户交互实用工具。
示例
请求用户确认
plugins: ['interact'] tasks: test: - @(if confirm("Are you sure?")) echo "OK, I will..."
让用户从几个选项中选择
使用 Z 提供默认值非常简单,如果没有在命令行中提供,它将询问用户。请参见此示例,它同时使用了 env
和 interact
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
这将显示一个选项列表
$ 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`"
运行此命令
$ z test
What is your name? [gerard]:
Hello gerard, my name is Linux
维护者
- Jochem Klaver jochem@zicht.nl