@@ -8,12 +8,14 @@ use {{ spec.title | caseUcfirst }}\Client;
88use Utopia\CLI\CLI ;
99use Utopia\Validator\Mock ;
1010use Utopia\CLI\Console ;
11+ use {{ spec.title | caseUcfirst }}\Parser ;
1112
1213$client = new Client ();
1314$cli = new CLI ();
15+ $parser = new Parser ();
1416
1517$cli ->
16- init(function () use ($cli ) {
18+ init(function () use ($cli , $parser ) {
1719
1820 if (array_key_exists (' help' , $cli -> getArgs())) {
1921 $taskName = $cli -> match()-> getName();
@@ -22,16 +24,13 @@ $cli->
2224 $params = $task -> getParams();
2325
2426 Console :: log(" \e [0;31;m {{ language.params.logo | raw }} \e [0m" ) ;
25-
26- printf (" \n Usage : {{ language.params.executableName }} client {$taskName } --[OPTIONS] \n\n " );
27- printf ($description );
28- printf (" Options:\n " );
29- $mask = " \t %-20.20s %-125.125s\n " ;
30-
31- foreach ($params as $key => $value ) {
32- if ($key ! == ' help' )
33- printf ($mask , $key , $value [' description' ]);
34- }
27+ Console :: log(" \n Usage : {{ language.params.executableName }} client {$taskName } --[OPTIONS] \n " );
28+ Console :: log($description );
29+ Console :: log(" Options:" );
30+ array_walk ($params , function (& $key ) {
31+ $key = $key [' description' ];
32+ });
33+ $parser -> formatArray($params );
3534 Console :: exit(0 );
3635 }
3736 });
7675
7776$cli
7877 -> task(' help' )
79- -> action(function () {
78+ -> action(function () use ( $parser ) {
8079 Console :: log(" \e [0;31;m {{ language.params.logo | raw }} \e [0m" ) ;
81- printf (" \n Usage : {{ language.params.executableName }} client [COMMAND]\n\n " );
82- printf (" Commands :\n " );
83- $mask = " \t %-20.20s %-125.125s\n " ;
84- printf ($mask , " setEndpoint" , " Set your server endpoint." );
85- printf ($mask , " setProject" , " Set the project you want to connect to." );
86- printf ($mask , " setKey" , " Set the API key for the project." );
87- printf ($mask , " setLocale" , " Set your preferred locale (eg: en-US)." );
88- printf (" \n Run '{{ language.params.executableName }} client COMMAND --help' for more information on a command.\n " );
80+ Console :: log(" \n Usage : {{ language.params.executableName }} client [COMMAND]\n " );
81+ Console :: log(" Commands :" );
82+ $commands = [
83+ " setEndpoint" => " Set your server endpoint." ,
84+ " setProject" => " Set the project you want to connect to." ,
85+ " setKey" => " Set the API key for the project." ,
86+ " setLocale" => " Set your preferred locale (eg: en-US)."
87+ ];
88+ $parser -> formatArray($commands );
89+ Console :: log(" \n Run '{{ language.params.executableName }} client COMMAND --help' for more information on a command." );
8990 });
9091
9192
0 commit comments