Skip to content

Commit e34b4cf

Browse files
author
Slavey Karadzhov
committed
Initial support for the interactive console line manual.
1 parent 8380b0b commit e34b4cf

File tree

5 files changed

+131
-13
lines changed

5 files changed

+131
-13
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
composer.phar
22
composer.lock
33
vendor/
4+
.project
5+
.buildpath
6+
.settings
7+
php-cs-fixer.phar

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"php" : ">=5.3.3",
2424
"openlss/lib-array2xml" : "dev-master",
2525
"zenddevops/webapi" : "dev-master",
26-
"mustangostang/spyc" : "dev-master"
26+
"mustangostang/spyc" : "dev-master",
27+
"slk/icm" : "dev-master"
2728
},
2829
"require-dev" : {
2930
"phpunit/phpunit" : "3.7.*",

module/Client/config/module.config.php

+5
Original file line numberDiff line numberDiff line change
@@ -258,5 +258,10 @@
258258
'template_path_stack' => array(
259259
__DIR__ .'/../views/',
260260
)
261+
),
262+
'view_helpers' => array(
263+
'invokables' => array(
264+
'figlet' => 'Slk\View\Helper\Figlet',
265+
)
261266
)
262267
);
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,70 @@
11
<?php
22
namespace Client\Controller;
3-
use Zend\Mvc\Controller\AbstractActionController;
3+
44
use Zend\View\Model\ViewModel;
55
use Zend\Stdlib\ResponseInterface as Response;
66
use Zend\Stdlib\RequestInterface as Request;
7-
use Zend\View\Renderer\PhpRenderer;
7+
use Zend\Stdlib\DispatchableInterface;
8+
use Zend\Mvc\InjectApplicationEventInterface;
9+
use Zend\EventManager\EventInterface as Event;
10+
use Zend\ServiceManager\ServiceLocatorAwareInterface;
11+
use Zend\ServiceManager\ServiceLocatorInterface;
12+
13+
use Slk\View\ICMRenderer;
814

915
/**
1016
* Manual Pages Controller
1117
*/
12-
class ManualController extends AbstractActionController
18+
class ManualController implements DispatchableInterface,
19+
ServiceLocatorAwareInterface,
20+
InjectApplicationEventInterface
1321
{
22+
protected $event;
23+
protected $serviceLocator;
24+
1425
public function dispatch(Request $request, Response $response = null)
1526
{
1627
$serviceManager = $this->getServiceLocator();
1728
$routeMatch = $this->getEvent()->getRouteMatch();
1829
$viewModel = new ViewModel();
1930
$viewModel->setTemplate('client/manual/'.strtolower($routeMatch->getParam('action')));
20-
if($serviceManager->has('viewrenderer')) {
21-
$renderer = $serviceManager->get('viewrenderer');
22-
} else {
23-
$renderer = new PhpRenderer();
24-
$renderer->setResolver($serviceManager->get('ViewResolver'));
25-
}
26-
27-
return $response->setContent($renderer->render($viewModel));
31+
$renderer = new ICMRenderer();
32+
$renderer->setConsoleAdapter($serviceManager->get('console'));
33+
$renderer->setResolver($serviceManager->get('ViewResolver'));
34+
$renderer->setHelperPluginManager($serviceManager->get('ViewHelperManager'));
35+
36+
$renderer->render($viewModel);
37+
}
38+
/* (non-PHPdoc)
39+
* @see \Zend\Mvc\InjectApplicationEventInterface::setEvent()
40+
*/
41+
public function setEvent(Event $event)
42+
{
43+
$this->event = $event;
44+
}
45+
46+
/* (non-PHPdoc)
47+
* @see \Zend\Mvc\InjectApplicationEventInterface::getEvent()
48+
*/
49+
public function getEvent()
50+
{
51+
return $this->event;
52+
}
53+
54+
/* (non-PHPdoc)
55+
* @see \Zend\ServiceManager\ServiceLocatorAwareInterface::setServiceLocator()
56+
*/
57+
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
58+
{
59+
$this->serviceLocator = $serviceLocator;
2860
}
61+
62+
/* (non-PHPdoc)
63+
* @see \Zend\ServiceManager\ServiceLocatorAwareInterface::getServiceLocator()
64+
*/
65+
public function getServiceLocator()
66+
{
67+
return $this->serviceLocator;
68+
}
69+
2970
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,68 @@
1-
This is the getting started ...
1+
[[[
2+
____ _ _ _ ____ _ _ _
3+
/ ___| ___| |_| |_(_)_ __ __ _ / ___|| |_ __ _ _ __| |_ ___ __| |
4+
| | _ / _ \ __| __| | '_ \ / _` | \___ \| __/ _` | '__| __/ _ \/ _` |
5+
| |_| | __/ |_| |_| | | | | (_| | ___) | || (_| | | | || __/ (_| |
6+
\____|\___|\__|\__|_|_| |_|\__, | |____/ \__\__,_|_| \__\___|\__,_|
7+
|___/
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
]]]
10+
>>>
11+
12+
Welcome to $script getting started tutorial.
13+
14+
To get more information about the different commands available in this tool type:
15+
$script --help.
16+
17+
Type below the command argument as given above to see a list of available command groups.
18+
>$_
19+
== --help
20+
=> args
21+
$_ $args
22+
23+
The result from this command would be....
24+
------
25+
26+
$result
27+
28+
------
29+
>>>
30+
Now if you want to see commands in one specific group you have to type command:<group-name>.
31+
For example in order to get a list of all codetracing commands you have to type:
32+
33+
$script command:codetracing
34+
35+
Can you type below the argument to show all commands in the group "high-level"?
36+
>$_
37+
== command:high-level
38+
=> args
39+
40+
$_ $args
41+
42+
Let's see what commands are in this group:
43+
$result
44+
45+
>>>$
46+
If you know a command but do not know its parameters then you can type:
47+
$script <command> --help.
48+
49+
Now check what are the arguments for the addTarget command.
50+
51+
>$_
52+
== /^\s*addTarget\s+\-\-help$/
53+
=== addTarget --help
54+
=> args
55+
56+
$_ $args
57+
58+
The result from this command would be....
59+
------
60+
61+
$result
62+
63+
------
64+
65+
[[[
66+
Adding Targets
67+
~~~~~~~~~~~~~~
68+
]]]

0 commit comments

Comments
 (0)