定制 sunkan/console-select 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sunkan/console-select

最新稳定版本:4.0.0

Composer 安装命令:

composer require sunkan/console-select

包简介

A fancy selection interface for symfony's console component.

README 文档

README

A fancy selection interface for symfony's console component.

Sample

Requirements

This project is intended to be run with one of these frameworks:

  • symfony/console 5.0+

Install

composer require sunkan/console-select

On Symfony

Add the EddIriarte\Console\Traits\SelectableInputs trait to your command class

# importing : \EddIriarte\Console\Helpers\SelectionHelper
# passing the input and output interfaces
$this->getHelperSet()->set(
  new SelectionHelper($this->input, $this->output)
);

Checkboxes

Useful when you need several answers from the user.

$selected = $this->select(
  'Select characters that appeared in "Star Wars,  Episode I - The phantom menace"',
  [
    'Ahsoka Tano',
    'Anakin Skywalker',
    'Boba Fett',
    'Chewbacca',
    'Count Dooku',
    'Darth Maul',
    'Darth Vader',
    'Finn',
    'Han Solo',
    'Jabba the Hutt',
    'Jar Jar Binks',
    'Kylo Ren',
    'Lando Calrissian',
    'Luke Skywalker',
    'Mace Windu',
    'Obi-Wan Kenobi',
    'Padmé Amidala',
    'Sheev Palpatine',
    'Poe Dameron',
    'Princess Leia Organa',
    'Qui-Gon Jinn',
    'Rey',
    'Watto',
    'Yoda',
  ]
);

Radio

Useful when you need the user to pick only one anwer from the list.

$selected = $this->select(
  'What is the name of the ancient Jedi master that lives at the swamps of Dagobah',
  [
    'Ahsoka Tano',
    'Anakin Skywalker',
    'Boba Fett',
    'Chewbacca',
    'Count Dooku',
    'Darth Maul',
    'Darth Vader',
    'Finn',
    'Han Solo',
    'Jabba the Hutt',
    'Jar Jar Binks',
    'Kylo Ren',
    'Lando Calrissian',
    'Luke Skywalker',
    'Mace Windu',
    'Obi-Wan Kenobi',
    'Padmé Amidala',
    'Sheev Palpatine',
    'Poe Dameron',
    'Princess Leia Organa',
    'Qui-Gon Jinn',
    'Rey',
    'Watto',
    'Yoda',
  ],
  false // third argument(bool) that allows multiple selections (default: true)
);

Still to do

  • Handle user-interruptions, such as Ctrl+C

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 1.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-02