theroadbunch/command-menu
Composer 安装命令:
composer require theroadbunch/command-menu
包简介
A simple class for command menus
README 文档
README
A simple menu for symfony console commands
a quick note:
This README assumes you have an understanding of creating and running a console command in the symfony ecosystem
Contents
Install using composer [?]
composer require theroadbunch/command-menu
Basic Usage
Creating, rendering, and using a menu in your symfony console command
<?php // ... use RoadBunch\CommandMenu\Menu; use RoadBunch\CommandMenu\Option; // ... public function execute(InputInterface $input, OutputInterface $output) { // create the menu $menu = new Menu($input, $output); // optional title $menu->title('Options'); // add options $menu->addOption('add', 'Add User'); $menu->addOption('delete', 'Delete User'); $menu->addOption('quit', 'Quit'); // render the menu $menu->render(); // prompt the user to make a selection $selection = $menu->promptForSelection(); // do work }
Output
Options
-------
1 Add User
2 Delete User
3 Quit
Please make a selection:
> |
If the user selects 1 then promptForSelection() will return "add", 2 will return "delete", and
3 will return "quit"
In the event a user selects something other than a given selector, promptForSelection() will return null
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-23