27
27
* @subpackage cake.cake.console
28
28
*/
29
29
class ConsoleOptionParser {
30
+
31
+ protected $ _description = null ;
32
+
33
+ protected $ _epilog = null ;
34
+
35
+ protected $ _options = array ();
36
+
37
+ protected $ _args = array ();
38
+
30
39
/**
31
40
* Construct an OptionParser for a given ARGV array.
32
41
*
@@ -44,9 +53,59 @@ class ConsoleOptionParser {
44
53
* By providing help text for your positional arguments and named arguments, the ConsoleOptionParser
45
54
* can generate a help display for you. You can view the help for shells by using the `--help` or `-h` switch.
46
55
*
47
- * @param array $args The array of arguments with the Shell/Task stripped off.
48
56
*/
49
- public function __construct ($ args ) {
57
+ public function __construct () {
58
+
59
+ }
60
+
61
+ /**
62
+ * Get or set the description text for shell/task
63
+ *
64
+ * @param string $text The text to set, or null if you want to read
65
+ * @return mixed If reading, the value of the description. If setting $this will be returned
66
+ */
67
+ public function description ($ text = null ) {
68
+ if ($ text !== null ) {
69
+ $ this ->_description = $ text ;
70
+ return $ this ;
71
+ }
72
+ return $ this ->_description ;
73
+ }
74
+
75
+ /**
76
+ * Get or set an epilog to the parser. The epilog is added to the end of
77
+ * the options and arguments listing when help is generated.
78
+ *
79
+ * @param string $text Text when setting or null when reading.
80
+ * @return mixed If reading, the value of the epilog. If setting $this will be returned.
81
+ */
82
+ public function epilog ($ text = null ) {
83
+ if ($ text !== null ) {
84
+ $ this ->_epilog = $ text ;
85
+ return $ this ;
86
+ }
87
+ return $ this ->_epilog ;
88
+ }
89
+
90
+ /**
91
+ * Add an option to the option parser. Options allow you to define optional or required
92
+ * parameters for your console application. Options are defined by the parameters they use.
93
+ *
94
+ * ### Params
95
+ *
96
+ * - `shortcut` - The single letter variant for this option, leave undefined for none.
97
+ * - `required` - Set to true to force this option to be required. An exception will be thrown
98
+ * when this option is not present.
99
+ * - `description` - Description for this option.
100
+ * - `type` - Require a certain type. Available types are `int` and `string`. If the options
101
+ * value is the wrong type an exception will be raised.
102
+ * - `default` - The default value for this option. If not defined the default will be null.
103
+ *
104
+ * @param string $name The name you want to the value to be parsed out as when options are parsed.
105
+ * @param array $params An array of parameters that define the behavior of the option
106
+ * @return ConsoleOptionParser returns $this.
107
+ */
108
+ public function addOption ($ name , $ params = array ()) {
50
109
51
110
}
52
111
}
0 commit comments