Code Monkey home page Code Monkey logo

cli-menu's People

Contributors

andreybolonin avatar authanram avatar aydinhassan avatar bmitch avatar bozhinov avatar ccsliinc avatar jackwh avatar jodiwarren avatar jtreminio avatar lachlankrautz avatar lynesth avatar mikeymike avatar mingtsay avatar nemanjan00 avatar octoper avatar robertmarsal avatar simonorono avatar simonovich avatar vesper8 avatar vinkla avatar vladreshet avatar williamokano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli-menu's Issues

Don't clear terminal until opening

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

CI

And badges

Disable appveyor

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 ๐Ÿ˜„

I get "not a valid TTY"

PHP Fatal error: Uncaught PhpSchool\CliMenu\Exception\InvalidTerminalException: Terminal "" is not a valid TTY
on windows 10 cmd :-)

Need some consistent way to select menu items

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 ?

Documentation

  • Inputs
    • Password
      • Custom validator
    • Number
      • Validation
      • Up + Down keys
    • Text
      • Validation
    • Building custom input
  • Using already prepared menu builder with addSubMenu
  • addItems & setItems
  • Custom control mapping
  • MenuMenuItem#getSubMenu
  • AsciiArtItem alternate text
  • Pass MenuStyle instance to dialogues and inputs
  • Borders
  • Auto center menu
  • 256 colours
  • redraw clear
  • top/bottom & left/right padding
  • Minimum requirements
  • New examples

PHP requirement

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.

Output Text

Hi, can you customize the text that will appear when choosing an item? Same as Flash Dialogue, but I do not want a "modal".

Tests

Shouldn't be too difficult ๐Ÿ˜„

Consistant API documentation in README

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?

Possibilities

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.

ERRO INSTALlATION

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.

Features in the next release

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

Prompt Dialogue

Hi.

I wonder if was good feature, having a prompt dialogue box to get data from user. What you think?

Issues with multiple submenus with same id

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 ?).

Option to not clear the terminal window

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.

Calendar

Would be great to add calendar out of the box

Use cli-menu via ssh on a Debian 7 server

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

How to use terminal background

I can see how it is possible to set the menu background color, however, I am trying to have it use the current terminal background color (see screenshot)

๏ปฟ
image

Usage with symfony/console

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();

Error with toggling item extra

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:

  • Initially, every item has ItemExtra false
  • In item callback, we call 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!

Contribution Offer

If you are keen to accept contribution PRs, I would be happy to provide fixes for the two items I reported to get started

Add separator line support in options - #70
If option item text is greater than width, it has syntax error - #71

Require POSIX

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?

Precompute rows generation

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 ?

Add ability to use own Item classes

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?

No cursor in terminal when exiting

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.