php-school / cli-menu Goto Github PK
View Code? Open in Web Editor NEW๐ฅ Build beautiful PHP CLI menus. Simple yet Powerful. Expressive DSL.
Home Page: http://www.phpschool.io
License: MIT License
๐ฅ Build beautiful PHP CLI menus. Simple yet Powerful. Expressive DSL.
Home Page: http://www.phpschool.io
License: MIT License
Is this possible?
Currently the terminal is cleared via some method in the CliMenu
__construct
This messes with the unit tests in the workshop as I'm testing the factory which creates the menus, it clears all the text output from PHPUnit
Check the longest ascii art line against the width of the terminal and prevent output if too large.
And badges
yo @mikeymike can you disable appveyor for PR's? I think you signed up with your GitHub so I don't have access. It's pretty annoying on PR's as they never pass anyway until we support Windows ๐
PHP Fatal error: Uncaught PhpSchool\CliMenu\Exception\InvalidTerminalException: Terminal "" is not a valid TTY
on windows 10 cmd :-)
We currently have $CliMenu->getItems()
which returns items indexed by position.
So let's say I need the 4th item in the menu, I need to use $CliMenu->getItems()[3]
.
This isn't a nice way of doing it... If I add new items before it, I need to change that line and it gets even worst if I have some AsciiArt above it because depending on the size, it's not even included in the items (if the art is bigger than the width).
I'm not sure how we should do that, looping over items with getText() might be too much...
Any idea ?
addSubMenu
we should put 5.6 in the composer.json. It would have probably been quicker to just do this and not create an issue. oh well.
Hi, can you customize the text that will appear when choosing an item? Same as Flash Dialogue, but I do not want a "modal".
Shouldn't be too difficult ๐
As @bmitch pointed out in #55 it does seem a little inconsistent between when we're showing a full example and a snippet of code.
Maybe this is just a case of adding something like ... snip
to the smaller API examples to make it more clear.
@AydinHassan thoughts?
Hey, this is cool start.. but, any plans to just convert or create new library when Forms: Input, Combo Box, Check Box? hehe! just saying.. this is a great installer and a CLI app to begin with.
Problem 1
- Installation request for php-school/cli-menu ^2.1 -> satisfiable by php-school/cli-menu[2.1.0].
- php-school/cli-menu 2.1.0 requires ext-posix * -> the requested PHP extension posix is missing from your system.
To enable extensions, verify that they are enabled in your .ini files:
- C:\xampp\php\php.ini
You can also run php --ini
inside terminal to see which files are used by PHP in CLI mode.
Hi All,
I really like your package and currently developing a cmd line app to use your menus, I have just noticed that the examples/input-* don't exist in version 2.1.0. Is this a new feature you're working on ? I would like to use these user input features and wondered when you expect to release this ?
thanks
In https://github.com/php-school/cli-menu/blob/master/test/Util/ColourUtilTest.php shouldn't we force the terminal to return 8 colours where we expect it to be ?
I mean that it's currently relying on the fact that Travis' terminal returns 8 colours when asked but it could change at some point.
Or at least handle it correctly. It crashes when trying to move the selection.
Hi.
I wonder if was good feature, having a prompt dialogue box to get data from user. What you think?
Hello :-),
I wonder if you have ever considered using the Hoa\Console
library, especially for the Cursor
, Window
and Readline
feature?
You will gain more statibility on more terminals since it is based on tput.
You might be interested by this blog post to understand what I am talking about, https://mnt.io/P/2015-01-04_Control_the_terminal_the_right_way.html.
Regards.
We currently can add multiple submenus with the same "id"
Example:
$menu = (new CliMenuBuilder)
->addSubMenu('Options')
->addItem(...)
->end()
->addSubMenu('Options')
->addItem(...)
->end()
->end()
Both of them work but only the second one has its parent set and can "Go Back" to the main menu.
We either need to prevent adding a menu with the same ID or, even better, handle it differently (maybe like the uniqid
that's used with split items ?).
Please see extended description here where it was first discovered
Hey,
right now when you open a menu, the window will get cleared and shows only the menu. That's ok for me and I can work with that but I prefer to not clear the window.
An option on the menu builder to turn it off would be nice.
Would be great to add calendar out of the box
It is actually fairly easy to test the menu by capturing STDOUT with PHPUnit. It would be good to properly test the drawing.
For example: https://github.com/php-school/cli-menu/blob/master/test/CliMenuTest.php#L65
Hi,
im trying to use the cli-menu on a Debian 7 Server with PHP 5.6 via ssh.
Script works perfectly on my local mac, but when im trying to start the menu script from remote server, there comes just nothing. Not a even an error or something.
Any idea about that?
Greetings from germany
Hey,
most people use symfony/console for their cli applications.
There you create a new ChoiceQuestion with all the answers and get the answer back as variable. This way you can continue with your script.
This package needs a callback function when an answer is selected. That means you break out of your current function. That makes it really difficult to integrate into symfony/console applications.
Would it be possible to provide this behaviour too?
Maybe:
$menu = (new CliMenuBuilder)
->setTitle('Basic CLI Menu')
->addItem('First Item')
->addItem('Second Item')
->addItem('Third Item')
->addLineBreak('-')
->inline()
->build();
$menu->open();
// execution pauses until an item is selected
$item = $menu->getSelectedItem();
Use case: I was writing up a menu where I want the user to select multiple menu items. I was using the ExtraItem to indicate which menu items were selected.
Here is an example to reproduce the problem:
<?php
use PhpSchool\CliMenu\CliMenu;
use PhpSchool\CliMenu\CliMenuBuilder;
use PhpSchool\CliMenu\MenuItem\MenuItemInterface;
require_once(__DIR__ . '/../vendor/autoload.php');
$itemCallable = function (CliMenu $menu) use ($selected) {
if ($menu->getSelectedItem()->showsItemExtra()) {
$menu->getSelectedItem()->hideItemExtra();
} else {
$menu->getSelectedItem()->showItemExtra();
}
$menu->redraw();
};
$menu = (new CliMenuBuilder)
->setTitle('Basic CLI Menu Custom Item Extra')
->addItem('First Item', $itemCallable)
->addItem('Second Item', $itemCallable)
->addItem('Third Item', $itemCallable)
->addLineBreak('-')
->setItemExtra('**')
->build();
$menu->open();
The primary take aways in the above example are:
false
showItemExtra
and do a redraw.The result is a PHP warning: Warning: str_repeat(): Second argument has to be greater than or equal to 0 in /path/to/cli-menu/src/CliMenu.php on line 319
and 319 is the following line of code in CliMenu::drawMenuItem:
str_repeat(' ', $this->style->getRightHandPadding(mb_strlen(s::stripAnsiEscapeSequence($row)))),
In addition, the menu renders incorrectly, the ItemExtra renders outside of the menu box.
Hope that's enough to go on, cheers! Great menu system, thanks!
Please see extended description here where it was first discovered
Using this configuration results in not being able to navigate the menu.
We should clean up the terminal classes to a single class and require POSIX functions.
I can't see a feasible method of us getting the Windows terminal class working without extra php extensions. @AydinHassan what do you think?
Why do we always recompute getRows() ?
Couldn't we save the result and only recompute it if the contentWidth (or anything else needed to get the correct outout, like if the text was modified) has changed ?
This is something we could do for all MenuItems with 2 variants for selectable ones.
What do you say @AydinHassan ?
We want them to look like that:
โ item
one
Instead of looking like this (which they currently do):
โ item
one
Hey,
I created my own Menu Item class in order to have key/values for my options. But I can't add it to the menu because the addMenuItem
method is private.
I also can't extend the CliMenuBuilder
class to add my own method that adds my Items because the $menuItems
property is private too.
Would be cool if the addMenuItem
method would be public or the $menuItems
property protected.
Is that a problem for you?
Use class_alias
on CliMenuBuilder
so we don't pointlessly break loads of code, we can maybe add a deprecation notice.
So I made #89 but it doesn't work as intended.
I think it's the restoreOriginalConfiguration which doesn't work in my case.
Adding enableCursor and enableEchoBack after the stty exec call in restoreOriginalConfiguration (inside php-school/terminal/UnixTerminal.php) makes it work.
(I need to add both, because just adding enableCursor gives the cursor back but removes the echo !!!)
Not sure if real issue or just specific case.
Noticed in the workshop. Access the options and then go back and select an exercise and the output is wiped even though menu->close()
is called prior to the output being written.
Really crazy weird bug.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.