Git Product home page Git Product logo

garden-cli's Issues

is it possible that argument are not checked against required flag?

It seems to me that, while there is code to check for options being required and not being provided, the same thing does not happen for arguments.
I have an example with a cli command requiring 3 arguments and an optional fourth. If I don't provide any argument, the program doesn't stop. Am i doing something wrong?

LogFormatter improvements

The LogFormatter right now is hardcoded to php://output. I want to be able to specify another output stream or even multiple output destinations, some of which may not be a file stream (ex. database, syslog). The garden-cli won't be responsible for doing any of the work or wiring these up; it just needs to make useful classes available to libraries.

Any changes must be backwards compatible.

Turn formatting on/off

I've been trying the library on windows and that doesn't support the bold or colored items you have in there by default. It would be great if there was a way to turn that off without having to fiddle with the libraries code.

PHP 8.1 Compatibility

Running garden-cli with PHP 8.1.5 gives me:

Deprecated: Return type of Garden\Cli\Schema\OptSchema::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Schema\OptSchema.php on line 231

Deprecated: Return type of Garden\Cli\Args::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 219

Deprecated: Return type of Garden\Cli\Args::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 236

Deprecated: Return type of Garden\Cli\Args::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 247

Deprecated: Return type of Garden\Cli\Args::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 259

Deprecated: Return type of Garden\Cli\Args::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 270

I can not push to new branch or create pull request. So... If okay, please help me doing these:
src\Schema\OptSchema.php
Line 231: Add return type: mixed
public function jsonSerialize() : mixed {

src\Args.php
Line 219: Add return type: mixed
public function jsonSerialize() : mixed {
Line 236: Add return type: bool
public function offsetExists($offset) : bool {
Line 247: Add return type: mixed
public function offsetGet($offset) : mixed {
Line 259: Add return type: void
public function offsetSet($offset, $value) : void {
Line 270: Add return type: void
public function offsetUnset($offset) : void {

Doing this will break compatibility with PHP below Version 7. But since the requirement for garden-cli is PHP 7 or above, then i think it's safe to do above changes.

Shortform of help doesn't work (on macos with zsh)

If I enter -? to get the help for a registered command as suggested, nothing happens.

$ php cli.php auth:token -? 
zsh: no matches found: -?

The long help with --help works like expected.

$ php cli.php auth:token --help
usage: cli.php auth:token [<options>]

Get token for credentials.

OPTIONS
  --help, -?   Display this help.
  --pass, -p   The Password.
  --user, -u   The Username.

It maybe has to do with macOS Monterey 12.6.5 (21G531) with zsh 5.8.1 (x86_64-apple-darwin21.0) installed.

Logger has no fluid interface

This does not work as documented:

$log = new TaskLogger();
$log->info('This is a message.')
    ->error('This is an error.') // outputs in red

The info() method has return type void in the trait. It only works like this:

$log = new TaskLogger();
$log->info('This is a message.');
$log->error('This is an error.');

Error "parseRaw expects an array"

I am trying to run https://github.com/bramus/mixed-content-scan. When I enter the command I get the following error message:

user:/home/www/user > files/swm2/composer/.composer/vendor/bin/mixed-content-scan https://example.com
Content-type: text/html; charset=UTF-8


Fatal error: Uncaught Exception: Garden\Cli\Cli::parseRaw expects an array in /files/swm2/composer/.composer/vendor/bramus/mixed-content-scan/vendor/vanilla/garden-cli/src/Cli.php:385
Stack trace:
#0 /files/swm2/composer/.composer/vendor/bramus/mixed-content-scan/vendor/vanilla/garden-cli/src/Cli.php(338): Garden\Cli\Cli->parseRaw(NULL)
#1 /files/swm2/composer/.composer/vendor/bramus/mixed-content-scan/bin/mixed-content-scan(40): Garden\Cli\Cli->parse(NULL, true)
#2 {main}
thrown in /files/swm2/composer/.composer/vendor/bramus/mixed-content-scan/vendor/vanilla/garden-cli/src/Cli.php on line 385

This error is thrown with both garden-cli version 1.6.3 and 2.0.
Using PHP 7.1.9 (cgi-fcgi).

How to fix this?

multiple arguments

There is a way to make a parameter accept multiple arguments?
Example:
$cli->arg( 'SINGLE', ''...,' true ); $cli->arg( 'MULTIPLE', ''...,' true. true // multiple );
Usage:
$ mycopy source target1 target2 target3....

Setting an option value via array syntax is not permitted

Hi

Why is setting values not permitted? Is there any workaround? Like get a copy of parsed options?
I want to use a "--dry" flag that will automatically activate few other options via boolean flags, so the user doesn't have to type 3 switches but just to use one.

$command= new Commando\Command();

//some optionsare defined here

//--dry flag should enable --skip --run --show flags
if ($command['dry']) {
    $command['skip'] = true;
    $command['run'] = true;
    $command['show'] = true;
}

Fatal error: Uncaught Exception: Setting an option value via array syntax is not permitted in C:\......1
Stack trace:

Allow Format -o=value or --option=value

This is more of a feature request than an actual issue, but still:

Please add an option to allow the equals symol to be used as a seperator for option name and value.
Right now you have no seperator at all or space (and thus a new element in argv) as a separator.
Having the = like the getopt from php does would be very welcome here.

Thanks in advance.

Print usage on demand

It would be nice if you could ask for the usage / help details programmatically (I.e public methods on the Cli class for: getUsage() or getHelp() / getHelp($command) )

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.