22
22
use OrangeHRM \Installer \Framework \InstallerCommand ;
23
23
use OrangeHRM \Installer \Util \InstanceCreationHelper ;
24
24
use Symfony \Component \Console \Input \InputInterface ;
25
+ use Symfony \Component \Console \Input \InputOption ;
25
26
use Symfony \Component \Console \Output \OutputInterface ;
26
27
27
28
class InstallerCountryListCommand extends InstallerCommand
@@ -34,6 +35,14 @@ public function getCommandName(): string
34
35
return 'install:country-list ' ;
35
36
}
36
37
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ protected function configure (): void
42
+ {
43
+ $ this ->addOption ('country ' , 'c ' , InputOption::VALUE_REQUIRED );
44
+ }
45
+
37
46
/**
38
47
* @inheritDoc
39
48
*/
@@ -45,6 +54,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
45
54
);
46
55
asort ($ countries );
47
56
$ countries = array_map (fn ($ country ) => strtolower ($ country ), $ countries );
57
+
58
+ $ country = $ input ->getOption ('country ' );
59
+ if ($ country !== null ) {
60
+ $ countries = array_flip ($ countries );
61
+ $ country = $ countries [strtolower ($ country )] ?? null ;
62
+ if ($ country == null ) {
63
+ $ this ->getIO ()->error ('Invalid country ' );
64
+ return self ::FAILURE ;
65
+ }
66
+ $ this ->getIO ()->writeln ($ country );
67
+ return self ::SUCCESS ;
68
+ }
69
+
48
70
$ countries = array_map (static function ($ k , $ v ) {
49
71
return " <comment>[ $ k]</comment> $ v " ;
50
72
}, array_keys ($ countries ), array_values ($ countries ));
0 commit comments