@@ -28,18 +28,73 @@ class SFlags extends AbstractObj
2828 // List of option allow array values.
2929 'arrayOpts ' => [], // ['names', 'status']
3030 // Special short style
31- // posix: -abc will expand: -a -b -c
32- // unix: -abc will expand: -a=bc
33- 'shortStyle ' => 'posix ' ,
31+ // gnu: ` -abc` will expand: ` -a -b -c`
32+ // posix: ` -abc` will expand: ` -a=bc`
33+ 'shortStyle ' => 'posix ' ,
3434 ];
3535
3636 /**
37+ * Special short style
38+ * gnu: `-abc` will expand: `-a -b -c`
39+ * posix: `-abc` will expand: `-a=bc`
40+ *
41+ * @var string
42+ */
43+ private $ shortStyle = 'posix ' ;
44+
45+ /**
46+ * Whether stop parse option on found unknown option
47+ *
48+ * @var bool
49+ */
50+ private $ stopOnUnknown = true ;
51+
52+ /**
53+ * Whether parse the remaining args {@see $rawArgs}.
54+ *
55+ * eg: 'arg=value' -> [arg => value]
56+ *
57+ * @var bool
58+ */
59+ private $ parseRawArgs = true ;
60+
61+ /**
62+ * Parsed options
63+ *
64+ * @var array
65+ */
66+ private $ opts = [];
67+
68+ /**
69+ * Parsed arguments
70+ *
71+ * @var array
72+ */
73+ private $ args = [];
74+
75+ /**
76+ * Parse options by pre-defined
77+ *
78+ * ```php
79+ * // element format:
80+ * // - k-v: k is option, v is value type
81+ * // - v: v is option, type is string.
82+ * $defines = [
83+ * 's,long', // use default type: string
84+ * // option => value type,
85+ * 's,long' => string,
86+ * 's' => bool,
87+ * 'long' => int,
88+ * 'long' => array, // TODO int[], string[]
89+ * ];
90+ * ```
91+ *
3792 * @param array $rawArgs
38- * @param array $settings
93+ * @param array $defines
3994 *
4095 * @return array
4196 */
42- public function parse (array $ rawArgs , array $ settings = []): array
97+ public function parseDefined (array $ rawArgs, array $ defines , array $ settings = []): array
4398 {
4499 $ this ->setSettings ($ settings );
45100 }
0 commit comments