adamgaskins / gumwrapper
A php wrapper for Gum: a tool for glamorous shell scripts 🎀
v0.1.2
2022-08-13 02:49 UTC
Requires
- php: ^7.4|^8.0
Requires (Dev)
- mockery/mockery: ^1.5
- pestphp/pest: ^1.20
This package is auto-updated.
Last update: 2024-12-11 09:18:06 UTC
README
A lightweight wrapper around Gum: A tool for glamorous shell scripts. See the Gum documentation for more documentation on the underlying features.
Getting Started
Install with composer:
composer install adamgaskins/gumwrapper
Usage:
$gum = new Gum(); $gum->choose([ 'apple', 'banana', 'pear' ])
The following platforms are currently supported. Please make a PR to BinManager.php
to add support for other platforms Gum supports!
- Apple M1
- Apple Intel
- Windows i386
- Windows x86_64
Reference
Choose
$result = $gum->choose([ 'apple', 'banana', 'pear', 'orange' ]); // example: "apple"
$gum->choose( $options = [ 'apple', 'banana', 'pear', 'orange' ], $limit = 2, // enable multiselect $height = 10 // scroll if more than 10 items );
Confirm
$result = $gum->confirm(); // example: true
$gum->confirm( $prompt = 'Are you sure?', $affirmativeText = 'Yeah!', $negativeText = 'Actually, no', $default = false // default to "no" option );
Input
$result = $gum->input('What is your name?'); // example: "Adam"
$gum->input( $placeholder = 'Password', $prompt = '> ', $initialValue = null, $charLimit = 400, $width = 10, $password = true );
Spin
Note: Do not write any output or call any other Gum commands before ->terminate()
-ing the spinner, or errors may occur.
$spinner = $gum->spin(); sleep(10); // do some long task $spinner->terminate();
$gum->spin( $title = 'Downloading files...', $spinner = 'pulse' );
Todo:
- Write
- Filter