File tree Expand file tree Collapse file tree 5 files changed +55
-13
lines changed Expand file tree Collapse file tree 5 files changed +55
-13
lines changed Original file line number Diff line number Diff line change @@ -377,6 +377,7 @@ public const DEFINE_ITEM = [
377
377
## Costom Settings
378
378
379
379
``` php
380
+ // -------------------- settings for parse option --------------------
380
381
381
382
/**
382
383
* Stop parse option on found first argument.
Original file line number Diff line number Diff line change @@ -153,10 +153,20 @@ public function getOpts(): array;
153
153
public function getArgs (): array ;
154
154
155
155
/**
156
+ * Get args help data
157
+ *
158
+ * @return array
159
+ * @psalm-return array<string, string>
160
+ */
161
+ public function getArgsHelpData (): array ;
162
+
163
+ /**
164
+ * Get opts help data
165
+ *
156
166
* @return array
157
167
* @psalm-return array<string, string>
158
168
*/
159
- public function getOptSimpleDefines (): array ;
169
+ public function getOptsHelpData (): array ;
160
170
161
171
/**
162
172
* @return bool
Original file line number Diff line number Diff line change @@ -856,19 +856,34 @@ public function getOpts(): array
856
856
/**
857
857
* @return array
858
858
*/
859
- public function getOptSimpleDefines (): array
859
+ public function getArgsHelpData (): array
860
860
{
861
- $ map = [];
862
- foreach ($ this ->options as $ name => $ define ) {
863
- $ names = $ define ['shorts ' ];
861
+ $ helpData = [];
862
+ foreach ($ this ->arguments as $ arg ) {
863
+ $ name = $ arg ->getHelpName ();
864
+ // append
865
+ $ helpData [$ name ] = $ arg ->getDesc (true );
866
+ }
867
+
868
+ return $ helpData ;
869
+ }
870
+
871
+ /**
872
+ * @return array
873
+ */
874
+ public function getOptsHelpData (): array
875
+ {
876
+ $ helpData = [];
877
+ foreach ($ this ->options as $ name => $ opt ) {
878
+ $ names = $ opt ['shorts ' ];
864
879
$ names [] = $ name ;
865
880
866
881
$ helpName = FlagUtil::buildOptHelpName ($ names );
867
-
868
- $ map [$ helpName ] = $ define [ ' desc ' ] ;
882
+ // append
883
+ $ helpData [$ helpName ] = $ opt -> getDesc ( true ) ;
869
884
}
870
885
871
- return $ map ;
886
+ return $ helpData ;
872
887
}
873
888
874
889
/**
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ abstract class FlagsParser implements ParserInterface
66
66
];
67
67
68
68
/**
69
- * TODO If locked, cannot add option and argument
69
+ * If locked, cannot add option and argument
70
70
*
71
71
* @var bool
72
72
*/
Original file line number Diff line number Diff line change 27
27
use function strpos ;
28
28
use function substr ;
29
29
use function trim ;
30
+ use function ucfirst ;
30
31
31
32
/**
32
33
* Class SFlags
@@ -889,19 +890,34 @@ public function getArgs(): array
889
890
/**
890
891
* @return array
891
892
*/
892
- public function getOptSimpleDefines (): array
893
+ public function getArgsHelpData (): array
893
894
{
894
- $ map = [];
895
+ $ helpData = [];
896
+ foreach ($ this ->argDefines as $ define ) {
897
+ $ name = $ define ['name ' ];
898
+
899
+ $ helpData [$ name ] = $ define ['desc ' ];
900
+ }
901
+
902
+ return $ helpData ;
903
+ }
904
+
905
+ /**
906
+ * @return array
907
+ */
908
+ public function getOptsHelpData (): array
909
+ {
910
+ $ helpData = [];
895
911
foreach ($ this ->optDefines as $ name => $ define ) {
896
912
$ names = $ define ['shorts ' ];
897
913
$ names [] = $ name ;
898
914
899
915
$ helpName = FlagUtil::buildOptHelpName ($ names );
900
916
901
- $ map [$ helpName ] = $ define ['desc ' ];
917
+ $ helpData [$ helpName ] = ucfirst ( $ define ['desc ' ]) ;
902
918
}
903
919
904
- return $ map ;
920
+ return $ helpData ;
905
921
}
906
922
907
923
/**
You can’t perform that action at this time.
0 commit comments