Skip to content

Commit

Permalink
Remove shortcuts (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis committed Aug 16, 2023
1 parent c9cfb2e commit cf71756
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
5 changes: 0 additions & 5 deletions Makefile
Expand Up @@ -26,8 +26,3 @@ test-all: ##@Project Run all project tests at once
@make test
@make codestyle
@make codestyle PATH_SRC=./demo


toc: ##@Project Generate table of contents
@echo "Generate table of contents"
@gh-md-toc --insert --no-backup --skip-header ./README.md
22 changes: 9 additions & 13 deletions README.md
Expand Up @@ -39,10 +39,6 @@
* [Useful projects and links](#useful-projects-and-links)
* [License](#license)
* [See Also](#see-also)

<!-- Created by https://github.com/ekalinin/github-markdown-toc -->
<!-- Added by: smetdenis, at: Thu Aug 10 15:37:25 +04 2023 -->

<!--te-->

## Why?
Expand Down Expand Up @@ -70,18 +66,18 @@ The library greatly extends the functionality of CLI App and helps make creating

* **Advanced Options**
* Features such as profiling for performance, timestamping, error muting, and specialized output modes (like cron and logstash modes) empower developers to refine their console outputs and diagnostics according to their specific needs.
* Display timing and memory usage information with `--profile` (`-X`) option.
* Show timestamp at the beginning of each message with `--timestamp` (`-T`) option.
* Mute any sort of errors. So exit code will be always `0` (if it's possible) with `--mute-errors` (`-M`).
* None-zero exit code on any StdErr message with `--non-zero-on-error` (`-Z`) option.
* For any errors messages application will use StdOut instead of StdErr `--stdout-only` (`-1`) option (It's on your own risk!).
* Disable progress bar animation for logs with `--no-progress` (`-P`) option.
* Display timing and memory usage information with `--profile` option.
* Show timestamp at the beginning of each message with `--timestamp` option.
* Mute any sort of errors. So exit code will be always `0` (if it's possible) with `--mute-errors`.
* None-zero exit code on any StdErr message with `--non-zero-on-error` option.
* For any errors messages application will use StdOut instead of StdErr `--stdout-only` option (It's on your own risk!).
* Disable progress bar animation for logs with `--no-progress` option.

* **Versatile Output Modes**
* The library provides different output formats catering to various use cases. Whether you're focusing on user-friendly text, logs, or integration with tools like ELK Stack, there's an output mode tailored for you.
* `--output-mode=text`. By default, text output format. Userfriendly and easy to read.
* `--output-mode=cron` (`-Ocron`). It's basically focused on logs output. It's combination of `--timestamp --profile --stdout-only --no-progress -vv --no-ansi`.
* `--output-mode=logstash` (`-Ologstash`). It's basically focused on Logstash format for ELK Stack. Also, it means `--stdout-only --no-progress -vv`.
* `--output-mode=cron`. It's basically focused on logs output. It's combination of `--timestamp --profile --stdout-only --no-progress -vv --no-ansi`.
* `--output-mode=logstash`. It's basically focused on Logstash format for ELK Stack. Also, it means `--stdout-only --no-progress -vv`.

* **Bonuses**
* There is a [multiprocess](#multi-processing) mode (please don't confuse it with multithreading) to speed up work with a monotonous dataset.
Expand Down Expand Up @@ -572,8 +568,8 @@ Notes:

## Tips & Tricks

* Define constant `\JBZOO_CLI_NO_PREDEFINED_SHORTCUTS=true` to disable all predefined shortcuts in options if you have conflicts.
* Use class `\JBZoo\Cli\Codes` to get all available exit codes.
* You can add extra context to any message. It will be serialized to JSON and displayed in the end of the message. Just use `CliHelper::getInstance()->appendExtraContext(['section' => ['var' => 'value']]);`


## Contributing
Expand Down
16 changes: 7 additions & 9 deletions src/CliCommand.php
Expand Up @@ -81,51 +81,49 @@ public function progressBar(
*/
protected function configure(): void
{
$definedShortcuts = !\defined('\JBZOO_CLI_NO_PREDEFINED_SHORTCUTS');

$this
->addOption(
'no-progress',
$definedShortcuts ? 'P' : null,
null,
InputOption::VALUE_NONE,
'Disable progress bar animation for logs. ' .
'It will be used only for <info>' . Text::getName() . '</info> output format.',
)
->addOption(
'mute-errors',
$definedShortcuts ? 'M' : null,
null,
InputOption::VALUE_NONE,
"Mute any sort of errors. So exit code will be always \"0\" (if it's possible).\n" .
"It has major priority then <info>--non-zero-on-error</info>. It's on your own risk!",
)
->addOption(
'stdout-only',
$definedShortcuts ? '1' : null,
null,
InputOption::VALUE_NONE,
"For any errors messages application will use StdOut instead of StdErr. It's on your own risk!",
)
->addOption(
'non-zero-on-error',
$definedShortcuts ? 'Z' : null,
null,
InputOption::VALUE_NONE,
'None-zero exit code on any StdErr message.',
)
->addOption(
'timestamp',
$definedShortcuts ? 'T' : null,
null,
InputOption::VALUE_NONE,
'Show timestamp at the beginning of each message.' .
'It will be used only for <info>' . Text::getName() . '</info> output format.',
)
->addOption(
'profile',
$definedShortcuts ? 'X' : '',
null,
InputOption::VALUE_NONE,
'Display timing and memory usage information.',
)
->addOption(
'output-mode',
$definedShortcuts ? 'O' : null,
null,
InputOption::VALUE_REQUIRED,
"Output format. Available options:\n" . CliHelper::renderListForHelpDescription([
Text::getName() => Text::getDescription(),
Expand Down

0 comments on commit cf71756

Please sign in to comment.