Skip to content

Commit 10e2324

Browse files
committed
Validate option lang
1 parent bcb250f commit 10e2324

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/Commands/ShowCommand.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ public function handle()
8282
$this->files = $this->filesFromKey();
8383

8484
$this->languages = $this->manager->languages();
85-
86-
if($this->option('lang') != null){
87-
$this->languages = explode(',',$this->option('lang'));
85+
86+
if ($this->option('lang') != null) {
87+
$languages = explode(',', $this->option('lang'));
88+
if (!empty($diffLangagues = array_diff($languages, $this->languages))) {
89+
return $this->error('Unknown Langauges [ '.implode($diffLangagues,',').' ]');
90+
}
91+
$this->languages = explode(',', $this->option('lang'));
8892
}
8993

9094
$this->table(
@@ -106,11 +110,11 @@ private function tableRows()
106110

107111
foreach ($this->files as $languageKey => $file) {
108112
foreach ($filesContent[$languageKey] = Arr::dot($this->manager->getFileContent($file)) as $key => $value) {
109-
if (! $this->shouldShowKey($key)) {
113+
if (!$this->shouldShowKey($key)) {
110114
continue;
111115
}
112116

113-
$output[$key]['key'] = $key;
117+
$output[$key]['key'] = $key;
114118
$output[$key][$languageKey] = $value;
115119
}
116120
}
@@ -190,11 +194,11 @@ private function shouldShowKey($key)
190194
return true;
191195
}
192196

193-
if (! $this->option('close') && $key != $this->key) {
197+
if (!$this->option('close') && $key != $this->key) {
194198
return false;
195199
}
196200

197-
if ($this->option('close') && ! Str::contains($key, $this->key)) {
201+
if ($this->option('close') && !Str::contains($key, $this->key)) {
198202
return false;
199203
}
200204
}

0 commit comments

Comments
 (0)