Git Product home page Git Product logo

cli's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar g105b avatar

Watchers

 avatar  avatar  avatar

Forkers

isabella232

cli's Issues

Throw exception when unknown argument provided

Named arguments --like-this or short versions like -l should only be accepted if they are defined. I just tried using a cli script with an incorrectly named argument and it just ignored it... easy mistake to make, but it would have been nice to have been recognised by the system. An error message like Invalid argument supplied: "--something" would have been nice.

Output streams

When a command outputs something, it needs to be grouped into its own output stream.

Each stream can be provided a different colour, after #4 is implemented. For non-coloured terminals, the name of the command that is being output can be shown along with a timestamp before the message.

For example, two long-running processes "time" and "status" that make output every few seconds:

[time] 2020-04-05 17:25:53
The time is twenty five minutes past five.

[status] 2020-04-05 17:25:59
OK

[time] 2020-04-05 17:26:03
The time is twenty six minutes past five.

[status]  2020-04-05 17:26:10
OK

Allow arguments to be set more than once

Not 100% sure how this will work, but it is common to be able to pass in multiple arguments of the same name.

For example: myapp mycommand --thing=123 --thing=456 --thing=789

Progress bar

Inspired from snap install on Ubuntu.

The bottom line of the terminal is used to display text progress and percent progress in a minimal way.

As the status changes of the long-running process (for example, each package name as is being installed by Composer), the text is updated, but also the background/text colours are inverted to show a progress bar.

A nice solution in a single line on the Cli.

Application should have "forced" command, rather than "default"

The setDefaultCommand function is used to allow calling a command that's registered on the Application without calling the command, which is useful for applications that only have one command.

However, the function was designed with one particular use-case in mind: a command that takes only Parameters and not NamedParameters. With NamedParameters, this functionality is impossible to use.

If the setDefaultCommand function was renamed to forceCommand, this would tell the Application that the provided command should always be run.

Would be extra useful to have #15 implemented for this too.

Handle the version number

--version is handled by the Application, but needs some work integrating with composer and reading through the composer.json.

Currently, the method of checking the version number is by looking the Composer's installed.json and finding a "bin" match, returning that version number. There is probably a better way.

Command::get* functions

All of the initialisation is currently made in the constructor. Add abstract get functions to the base Command class to enforce the following:

  • getName():string
  • getParameters():???

Not only does this force the developer to implement all required parts of a Command, but there are plans to add logic to the abstract Command constructor, and I personally prefer not to have to chain parent constructor calls.

Aligned tabs

For example, in the repository PHP.Gt/Cron the help output message looks like this:

PHP.Gt Cron

Available commands:
 • run	Start a long-running process to execute each job when it is due
 • validate	Check the syntax of your crontab file and that the jobs exist

It should be possible to make tabs line up automatically in certain "table" outputs.

Example parameter value shows up in help output incorrectly

If a parameter is given an example value, it should be shown in the --help output. It's currently being shown, but it doesn't make sense where it's being output.

Example of what's currently happeneing:

$ myscript --help
Usage: mycommand exampleNamedParameter [--startFrom|-s 12345]

  -s, --startFrom      (Optional) Provide an ID to start from

Maybe just an "e.g." would make more sense.

Named parameter examples

When listing out the named parameters, use uppercase example usage, for example:

Error: Not enough arguments passed. Passed: 0 required: 1.
Usage: create PROJECT_NAME [--blueprint|-b BLUEPRINT_NAME]

currently PROJECT_NAME is shown as name.

Stream stacking

When an output stream emits the same message more than once, it would be extremely useful to "stack" the stream.

Issue #5 defines the feature of having one or more output streams. After this is implemented, a follow-on feature is to stack similar messages.

If the same message is output from the same script, rather than outputting it again, mark it with the number of repetitions instead.

[time] 2020-04-05 17:25:53
The time is twenty five minutes past five.

[time] 2020-04-05 17:26:03
The time is twenty six minutes past five.

[status]  2020-04-05 17:26:10 (7)
OK

Chained letter parameters

Unix style parameters (single letters) can be chained together, but currently this is not possible in PHP.Gt/Cli

Example

tar --create --gzip --file myarchive.tar.gz
# equal to:
tar -c -z -f myarchive.tar.gz
# equal to:
tar -czf myarchive.tar.gz

Colour

Colour the output in a consistent manner.

output("some text", Colour::GREEN); // single green message, resets afterwards
setOutputColour(Colour::RED); // set default colour to reset to
resetOutputColour(); // reset to default colour

Must not use the word Colour because of the American/British spelling.

Get help for individual commands (`help commandName`)

app help is a nice way to get help about the available commands, but getting a command's parameters wrong is currently the only way to see the example usage for each command.

app help commandName is a good solution for this. Possibly needs to have "Type app help commandName for help with a specific command" added to the bottom of the help message.

Application::exit

Allow setting an exit status code in the application logic to be exited with in the exit function, called after run has completed.

Deprecation notices: Cli

Return type of Gt\Cli\Argument\ArgumentList::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/g105b/Code/Persomic/website/vendor/phpgt/cli/src/Argument/ArgumentList.php on line 145

Set default command

The default command is automatically set to help but some commands would be nice to call via just the application's name.

Parameters should still be passed through, but obviously named parameters would not work like this.

Sections of output

It would be useful to refactor and enhance the output from just simple writeLine usage.

Idea:

$section = new OutputSection("The title of this section:");
$section->writeLine("Some text that will be indented", Colour::GREEN);

Oh, but Americans will hate the word Colour, so something else should be used.

Argument order

Should the argument order matter?

Currently, looking at PHP.Gt/Sync, this command fails:

sync --pattern * --symlink path/to/source path/to/dest

but this command succeeds:

sync path/to/source path/to/dest --pattern * --symlink

Shouldn't they both be synonymous?

Make --help synonymous to help

Many unix programs accept --help as an argument. phpgt/cli uses "help" as a command name, but it would help discoverability of functionality to users if --help worked too, especially for applications with a default command other than help, thanks to #23.

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.