2017 © Pedro Peláez
 

library jobber

A slim library for printing typical CLI job output.

image

volnix/jobber

A slim library for printing typical CLI job output.

  • Friday, August 14, 2015
  • by volnix
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,094 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 4 % Grown

The README.md

Jobber

Build Status Downloads Latest Stable Version Code Coverage, (*1)

Jobber is a super-slim library for printing output from a CLI job. It supports command-line colors through the use of kevinlebrun/colors.php, a well-revered CLI color library., (*2)

It was built with simplicity in mind, as printing job output should be the least of your worries when building CLI-based scripts., (*3)

Example output from Jobber

***************************************************
2015-01-23 15:52:35 - Starting test_name

INFO: 2015-01-23 15:52:35 - foo
WARNING: 2015-01-23 15:52:35 - bar
SUCCESS: 2015-01-23 15:52:35 - baz
ERROR: 2015-01-23 15:52:35 - qux

2015-01-23 15:52:35 - Execution Time: 0.0 seconds / Peak memory usage: 3.22 Mb
***************************************************

Installation

Command line:, (*4)

composer require volnix/jobber:~1.0

composer.json:, (*5)

{
    "name": "your/application",
    "require": {
        "volnix/jobber": "~1.0"
    }
}

Usage

Typically the printer (Volnix/Jobber/Printer) will be started, then stopped. The start method prints out the job name and and some asterisks to fence off this job's output. The stop method prints memory usage, runtime, and more fences., (*6)

use Volnix/Jobber/Printer;

Printer::start('my_job_name');
Printer::info('Something happened, but it is not super important.');
Printer::stop();

Jobber also supports getting the output out of the printer in plain-text. This is especially useful for logging job output somewhere., (*7)

Printer::start('my_job_name');
Printer::info('Something happened, but it is not super important.');
Printer::stop();

$my_logger->info(Printer::getOutput());

All message types:, (*8)

  • Info (Printer::info())
  • Warning (Printer::warning())
  • Success (Printer::success())
  • Error (Printer::error())
  • Fatal (Printer::fatal())
    • Note: fatal is merely an alias for error and stop in one call

If you desire to toggle verbosity on your job, this is supported. This will only disable info messages, while still allowing others to come through., (*9)

// turn off verbosity, disabling info messages
Printer::setVerbosity(false);

Note: info messages will still be returned when calling Printer::getOutput() for logging purposes, (*10)

If you desire to run multiple job "sessions" in one command, you can reset the printer., (*11)

// do job 1
Printer::start('job_number_1');
// do something in your code...
Printer::success('Something good happened.');
Printer::stop();

// reset the printer
Printer::reset();

// start job 2
Printer::start('job_number_2');
// ...

Finally, you may use sprintf-style messages as well by passing a tokenized (%s, %d, etc.) string as your first argument and an array of tokens as your second., (*12)

// printing with tokens
Printer::start('something job');
Printer::info('Exported %d records to %s.', [10, '/filepath/something/here.txt']); // "Exported 10 records to /filepath/something/here.txt"

The Versions

14/08 2015

dev-master

9999999-dev https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas

14/08 2015

1.4.2

1.4.2.0 https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas

29/01 2015

1.4.1

1.4.1.0 https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas

29/01 2015

1.4.0

1.4.0.0 https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas

27/01 2015

1.3.0

1.3.0.0 https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas

27/01 2015

1.2.0

1.2.0.0 https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas

26/01 2015

1.1.0

1.1.0.0 https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas

26/01 2015

1.0.1

1.0.1.0 https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas

23/01 2015

1.0.0

1.0.0.0 https://github.com/volnix/jobber

A slim library for printing typical CLI job output.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nick Volgas