nategood / commando

An Elegant CLI Library for PHP
MIT License
798 stars 80 forks source link

Added support for run() and created function for terminal errors #69

Closed cwbeck closed 5 years ago

cwbeck commented 7 years ago

Added support for run() and created function for terminal errors

nategood commented 7 years ago

Sorry if I'm being naive here, but what's the purpose of run? @cwbeck

cwbeck commented 7 years ago

__destruct() causes errors not to be thrown properly. This allows it to be called directly so errors can be caught. It's a PHP issue.

NeoVance commented 7 years ago

-1 use parse.

Your try block should not be around the definition of the options. Errors will be thrown when the tokens are parsed. This happens when you access an option key for the first time.

$cmd->option('c');

try {
    $cmd['c']; // calls $cmd->parse()
} catch(Exception $e) {
    ...
}
tolidano commented 5 years ago

Ported to https://github.com/tolidano/commandox/pull/21