1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Ember Db - An embeddable document database for php. |
4
|
|
|
* Copyright (C) 2016 Alexander During |
5
|
|
|
* |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU General Public License as published by |
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
* (at your option) any later version. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU General Public License |
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
* |
19
|
|
|
* @link http://github.com/alexanderduring/php-ember-db |
20
|
|
|
* @copyright Copyright (C) 2016 Alexander During |
21
|
|
|
* @license http://www.gnu.org/licenses GNU General Public License v3.0 |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace EmberDb\Client; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The class Options is responsible for representing the provided |
28
|
|
|
* command line options at start up. |
29
|
|
|
*/ |
30
|
|
|
class Options |
31
|
|
|
{ |
32
|
|
|
public $workingDirectory; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function __construct() |
37
|
|
|
{ |
38
|
|
|
// command line options |
39
|
|
|
$longopts = array( |
40
|
|
|
"directory::" |
41
|
|
|
); |
42
|
|
|
$options = getopt('', $longopts); |
43
|
|
|
|
44
|
|
|
// working directory |
45
|
|
|
$workingDirectory = array_key_exists('directory', $options) ? $options['directory'] : '.'; |
46
|
|
|
if ($workingDirectory[0] != '/') { |
47
|
|
|
$workingDirectory = './'.$workingDirectory; |
48
|
|
|
} |
49
|
|
|
$this->workingDirectory = realpath($workingDirectory); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|