-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathResolve.php
43 lines (36 loc) · 1.04 KB
/
Resolve.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Swaggest\JsonCli;
use Swaggest\JsonDiff\Exception;
use Swaggest\JsonDiff\JsonPointer;
use Yaoi\Command\Definition;
use Yaoi\Command\Option;
class Resolve extends Base
{
public $pointer;
public $path;
/**
* @param Definition $definition
* @param \stdClass|static $options
*/
static function setUpDefinition(Definition $definition, $options)
{
$options->path = Option::create()->setType()->setIsUnnamed()
->setDescription('Path to JSON/YAML file');
$options->pointer = Option::create()->setType()->setIsUnnamed()
->setDescription('JSON Pointer, example /key4/1/a');
}
/**
* @throws ExitCode
*/
public function performAction()
{
$jsonData = $this->readData($this->path);
try {
$this->out = JsonPointer::getByPointer($jsonData, $this->pointer);
} catch (Exception $e) {
$this->response->error($e->getMessage());
throw new ExitCode('', 1);
}
$this->postPerform();
}
}