Skip to content

Commit bc7d128

Browse files
committed
enforce usage of tabs for indentation #5226 #6563
1 parent 6039b82 commit bc7d128

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

server/lib/classes/cli.inc.php

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,52 @@
3030

3131
class cli {
3232

33-
private $cmd_opt = array();
34-
35-
// Add commandline option map
36-
protected function addCmdOpt($cmd_opt) {
37-
$this->cmd_opt = $cmd_opt;
38-
}
39-
40-
// Get commandline option map
41-
protected function getCmdOpt() {
42-
return $this->cmd_opt;
43-
}
44-
45-
// Run command module
46-
public function process($arg) {
47-
$function = '';
48-
$opt_string = '';
49-
$last_arg = 1;
50-
for($n = 1; $n < count($arg); $n++) {
51-
$a = ($n > 1)?$a.':'.$arg[$n]:$arg[$n];
52-
if(isset($this->cmd_opt[$a])) {
53-
$function = $this->cmd_opt[$a];
54-
$last_arg = $n + 1;
55-
}
56-
}
33+
private $cmd_opt = array();
34+
35+
// Add commandline option map
36+
protected function addCmdOpt($cmd_opt) {
37+
$this->cmd_opt = $cmd_opt;
38+
}
39+
40+
// Get commandline option map
41+
protected function getCmdOpt() {
42+
return $this->cmd_opt;
43+
}
44+
45+
// Run command module
46+
public function process($arg) {
47+
$function = '';
48+
$opt_string = '';
49+
$last_arg = 1;
50+
for($n = 1; $n < count($arg); $n++) {
51+
$a = ($n > 1) ? $a . ':' . $arg[$n] : $arg[$n];
52+
if(isset($this->cmd_opt[$a])) {
53+
$function = $this->cmd_opt[$a];
54+
$last_arg = $n + 1;
55+
}
56+
}
5757

5858
// Check function name
59-
if(!preg_match("/[a-z0-9\-]{0,20}/",$function)) die("Invalid commandline option\n");
60-
61-
// Build new arg array of the remaining arguments
62-
$new_arg = [];
63-
if($last_arg < count($arg)) {
64-
for($n = $last_arg; $n < count($arg); $n++) {
65-
$new_arg[] = $arg[$n];
66-
}
67-
}
68-
69-
if($function != '') {
70-
$this->$function($new_arg);
71-
} else {
59+
if(!preg_match("/[a-z0-9\-]{0,20}/", $function)) die("Invalid commandline option\n");
60+
61+
// Build new arg array of the remaining arguments
62+
$new_arg = [];
63+
if($last_arg < count($arg)) {
64+
for($n = $last_arg; $n < count($arg); $n++) {
65+
$new_arg[] = $arg[$n];
66+
}
67+
}
68+
69+
if($function != '') {
70+
$this->$function($new_arg);
71+
} else {
7272
$this->showHelp($new_arg);
73-
//$this->error("Invalid option");
74-
}
75-
}
73+
//$this->error("Invalid option");
74+
}
75+
}
7676

77-
// Query function
78-
public function simple_query($query, $answers, $default, $name = '') {
77+
// Query function
78+
public function simple_query($query, $answers, $default, $name = '') {
7979
global $autoinstall, $autoupdate;
8080
$finished = false;
8181
do {
@@ -93,7 +93,7 @@ public function simple_query($query, $answers, $default, $name = '') {
9393
}
9494
} else {
9595
$answers_str = implode(',', $answers);
96-
$this->swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: ');
96+
$this->swrite($this->lng($query) . ' (' . $answers_str . ') [' . $default . ']: ');
9797
$input = $this->sread();
9898
}
9999

@@ -115,7 +115,7 @@ public function simple_query($query, $answers, $default, $name = '') {
115115
$finished = true;
116116
}
117117

118-
} while ($finished == false);
118+
} while($finished == false);
119119
$this->swriteln();
120120
return $answer;
121121
}
@@ -135,7 +135,7 @@ public function free_query($query, $default, $name = '') {
135135
$input = $autoupdate[$name];
136136
}
137137
} else {
138-
$this->swrite($this->lng($query).' ['.$default.']: ');
138+
$this->swrite($this->lng($query) . ' [' . $default . ']: ');
139139
$input = $this->sread();
140140
}
141141

@@ -145,31 +145,31 @@ public function free_query($query, $default, $name = '') {
145145
die();
146146
}
147147

148-
$answer = ($input == '') ? $default : $input;
148+
$answer = ($input == '') ? $default : $input;
149149
$this->swriteln();
150150
return $answer;
151151
}
152152

153-
public function lng($text) {
153+
public function lng($text) {
154154
return $text;
155155
}
156156

157-
public function sread() {
158-
$input = fgets(STDIN);
159-
return rtrim($input);
160-
}
161-
162-
public function swrite($text = '') {
163-
echo $text;
164-
}
165-
166-
public function swriteln($text = '') {
167-
echo $text."\n";
168-
}
169-
170-
public function error($msg) {
171-
$this->swriteln($msg);
172-
die();
173-
}
157+
public function sread() {
158+
$input = fgets(STDIN);
159+
return rtrim($input);
160+
}
161+
162+
public function swrite($text = '') {
163+
echo $text;
164+
}
165+
166+
public function swriteln($text = '') {
167+
echo $text . "\n";
168+
}
169+
170+
public function error($msg) {
171+
$this->swriteln($msg);
172+
die();
173+
}
174174

175175
}

0 commit comments

Comments
 (0)