2017 © Pedro Peláez
 

library console

Strukt CLI Console

image

strukt/console

Strukt CLI Console

  • Friday, July 27, 2018
  • by pitsolu
  • Repository
  • 1 Watchers
  • 1 Stars
  • 169 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 10 % Grown

The README.md

Strukt Console

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

This is a console framework that utilises docblock to parse command description and format., (*2)

IMPORTANT

This package uses docblock to generate your commands. The docblock must be in single spaces and NOT tabs. Be conservative with the spaces and don't leave any that are unnecessary otherwise the commands will not work., (*3)

Usage

Sample Command:, (*4)

namespace Command;

use Strukt\Console\Input;
use Strukt\Console\Output;

/**
* mysql:auth          MySQL Authentication
* 
* Usage:
*   
*      mysql:auth <database> --username <username> --password <password> [--host <127.0.0.1>]
*
* Arguments:
*
*      database  MySQL database name - optional argument
* 
* Options:
* 
*      --username -u   MySQL Username
*      --password -p   MySQL Password
*      --host -h       MySQL Host - optional default 127.0.0.1
*/
class MySQLAuth extends \Strukt\Console\Command{ 

    public function execute(Input $in, Output $out){

        $out->add(sprintf("%s:%s:%s", 
                            $in->get("database"), 
                            $in->get("username"), 
                            $in->get("password")));
    }
}

Add this in your executable file:, (*5)

#!/usr/bin/php
<?php
$app = new Strukt\Console\Application("Strukt Console");
$app->add(new Command\MySQLAuth);
$app->run($_SERVER["argv"]);

Call command:, (*6)

$ php console mysql:auth payroll -u root -p p@55w0rd

Prompt for input and masked input, you may but need not describe promted input in command docblock:, (*7)

...
//prompt for input
$username = $in->getInput("Username:");
$nickname = $in->getInput("Nickname:");
//masked input
$password = $in->getMaskedInput("Password:");
$cpassword = $in->getMaskedInput("Confirm Password:");
...

The Versions

27/07 2018

dev-master

9999999-dev

Strukt CLI Console

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Moderator

02/07 2017

1.0.0

1.0.0.0

Strukt CLI Console

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Moderator