Skip to content

Commit

Permalink
Add _doRun() to execute the actual application logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed May 24, 2017
1 parent 4057c6b commit 6ad74a1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
Expand Up @@ -21,26 +21,36 @@ public function __construct()
'epilog' => 'Please report any bugs to https://bugs.horde.org.',
'description' => 'This is a Horde CLI application',
'version' => '%prog 1.0.0',
'optionList' => array(
new Horde_Argv_Option(
'-f', '--foo',
array(
'action' => 'store_const',
'const' => 42,
'dest' => 'bar',
'help' => 'Enable bar.',
)
),
new Horde_Argv_Option(
'-i', '--int',
array(
'action' => 'store',
'type' => 'int',
'help' => 'An integer.',
)
)
)
)
);
$this->addOption(
'-f', '--foo',
array(
'action' => 'store_const',
'const' => 42,
'dest' => 'bar',
'help' => 'Enable bar.',
)
);
$this->addOption(
'-i', '--int',
array(
'action' => 'store',
'type' => 'int',
'help' => 'An integer.',
)
);
}

/**
* Excecutes the actual application logic.
*/
protected function _doRun()
{
if ($this->values->bar) {
$this->message('The answer is ' . $this->values->bar, 'cli.success');
} else {
$this->message('You didn\'t pass --foo', 'cli.warning');
}
}
}
8 changes: 8 additions & 0 deletions framework/Cli_Application/lib/Horde/Cli/Application.php
Expand Up @@ -143,5 +143,13 @@ public function __set($property, $value)
public function run()
{
list($this->_values, $this->_arguments) = $this->_parser->parseArgs();
$this->_doRun();
}

/**
* Excecutes the actual application logic.
*/
protected function _doRun()
{
}
}

0 comments on commit 6ad74a1

Please sign in to comment.