2017 © Pedro Peláez
 

library get_opt

Utility class for manage scripts arguments

image

alphayax/get_opt

Utility class for manage scripts arguments

  • Wednesday, April 18, 2018
  • by alphayax
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4,831 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 9 % Grown

The README.md

Get Opt

A library to manage scripts arguments, (*1)

Latest Stable Version Latest Unstable Version pakagist, (*2)

Travis Coverage Status Codacy Badge, (*3)

License Total Downloads, (*4)

Features

  • Singleton pattern
  • Auto generate help
  • Manage short and long option (-a --abc)
  • Manage values and multiple values (-v /toto -v /tutu)
  • Manage required options

Examples

Check if a parameter (specified via a letter or a name) is set

$Args = \alphayax\utils\cli\GetOpt::getInstance();
$Args->setDescription('This script is a tiny example to show library features');
$verboseOption = $Args->addOpt('v', 'verbose', 'Verbose Mode');

$Args->parse();

$isVerboseMode = $verboseOption->isPresent();

Get the value of the --file option

$Args = \alphayax\utils\cli\GetOpt::getInstance();
$Args->setDescription('This script is a tiny example to show library features');
$fileOption = $Args->addOpt('f', 'file', 'File name', true);

$Args->parse();

// Check if file option is specified (via -f or --file)
if( $fileOption->isPresent()){
    $fileName = $fileOption->getValue();
}

Auto-generated Help

Example of help output (if the -h or --help flag is specified) :, (*5)

   Description
    This script is a tiny example to show library features

   Usage
    /usr/bin/php a.php [OPTIONS]

   Options
    -d                          Debug mode
                --dry-run       Dry Run mode
                --file <value>  Specify the file name
    -h          --help          Display help
    -n <value>                  [REQUIRED] Number of lines
    -v          --verbose       Verbose Mode

The Versions

18/04 2018

dev-master

9999999-dev

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

18/04 2018

3.1.0

3.1.0.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

26/11 2017

3.0.0

3.0.0.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

26/11 2017

2.1.1

2.1.1.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

26/11 2017

2.1.0

2.1.0.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

22/11 2017

2.0.2

2.0.2.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

19/11 2017

2.0.1

2.0.1.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

19/11 2017

2.0.0

2.0.0.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

16/11 2017

1.0.2

1.0.2.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

29/10 2017

1.0.1

1.0.1.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

18/06 2016

1.0.0

1.0.0.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

18/06 2016

0.0.2

0.0.2.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni

18/06 2016

0.0.1

0.0.1.0

Utility class for manage scripts arguments

  Sources   Download

LGPL-2.1

The Development Requires

by Yann Ponzoni