You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* No need to carry the :lines: directive around anymore.
* Display php opening tag.
* Add closing tag for mixed HTML.
* Remove unneeded comment.
* Convert comment.
* Convert comment to HTML.
Copy file name to clipboardExpand all lines: user_guide_src/source/cli/cli_library.rst
-21Lines changed: 0 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,41 +34,34 @@ handled with the ``prompt()`` or ``promptByKey()`` method.
34
34
You can provide a question by passing it in as the first parameter:
35
35
36
36
.. literalinclude:: cli_library/002.php
37
-
:lines: 2-
38
37
39
38
You can provide a default answer that will be used if the user just hits enter by passing the default in the
40
39
second parameter:
41
40
42
41
.. literalinclude:: cli_library/003.php
43
-
:lines: 2-
44
42
45
43
You can restrict the acceptable answers by passing in an array of allowed answers as the second parameter:
46
44
47
45
.. literalinclude:: cli_library/004.php
48
-
:lines: 2-
49
46
50
47
Finally, you can pass :ref:`validation <validation>` rules to the answer input as the third parameter:
51
48
52
49
.. literalinclude:: cli_library/005.php
53
-
:lines: 2-
54
50
55
51
Validation rules can also be written in the array syntax:
56
52
57
53
.. literalinclude:: cli_library/006.php
58
-
:lines: 2-
59
54
60
55
**promptByKey()**
61
56
62
57
Predefined answers (options) for prompt sometimes need to be described or are too complex to select via their value.
63
58
``promptByKey()`` allows the user to select an option by its key instead of its value:
64
59
65
60
.. literalinclude:: cli_library/007.php
66
-
:lines: 2-
67
61
68
62
Named keys are also possible:
69
63
70
64
.. literalinclude:: cli_library/008.php
71
-
:lines: 2-
72
65
73
66
Finally, you can pass :ref:`validation <validation>` rules to the answer input as the third parameter, the acceptable answers are automatically restricted to the passed options.
74
67
@@ -82,18 +75,15 @@ or a complex table of information that wraps to the user's terminal window. At t
82
75
method which takes the string to output as the first parameter:
83
76
84
77
.. literalinclude:: cli_library/009.php
85
-
:lines: 2-
86
78
87
79
You can change the color of the text by passing in a color name as the second parameter:
88
80
89
81
.. literalinclude:: cli_library/010.php
90
-
:lines: 2-
91
82
92
83
This could be used to differentiate messages by status, or create 'headers' by using a different color. You can
93
84
even set background colors by passing the color name in as the third parameter:
94
85
95
86
.. literalinclude:: cli_library/011.php
96
-
:lines: 2-
97
87
98
88
The following foreground colors are available:
99
89
@@ -134,7 +124,6 @@ the same line, from different calls. This is especially helpful when you want to
134
124
print "Done" on the same line:
135
125
136
126
.. literalinclude:: cli_library/012.php
137
-
:lines: 2-
138
127
139
128
**color()**
140
129
@@ -144,7 +133,6 @@ an EOL after printing. This allows you to create multiple outputs on the same ro
144
133
it inside of a ``write()`` method to create a string of a different color inside:
145
134
146
135
.. literalinclude:: cli_library/013.php
147
-
:lines: 2-
148
136
149
137
This example would write a single line to the window, with ``fileA`` in yellow, followed by a tab, and then
150
138
``/path/to/file`` in white text.
@@ -157,7 +145,6 @@ for errors so they don't have to sift through all of the information, only the a
157
145
exactly as you would the ``write()`` method:
158
146
159
147
.. literalinclude:: cli_library/014.php
160
-
:lines: 2-
161
148
162
149
**wrap()**
163
150
@@ -166,23 +153,20 @@ This might be useful when displaying a list of options with descriptions that yo
166
153
window and not go off screen:
167
154
168
155
.. literalinclude:: cli_library/015.php
169
-
:lines: 2-
170
156
171
157
By default, the string will wrap at the terminal width. Windows currently doesn't provide a way to determine
172
158
the window size, so we default to 80 characters. If you want to restrict the width to something shorter that
173
159
you can be pretty sure fits within the window, pass the maximum line-length as the second parameter. This
174
160
will break the string at the nearest word barrier so that words are not broken.
175
161
176
162
.. literalinclude:: cli_library/016.php
177
-
:lines: 2-
178
163
179
164
You may find that you want a column on the left of titles, files, or tasks, while you want a column of text
180
165
on the right with their descriptions. By default, this will wrap back to the left edge of the window, which
181
166
doesn't allow things to line up in columns. In cases like this, you can pass in a number of spaces to pad
182
167
every line after the first line, so that you will have a crisp column edge on the left:
183
168
184
169
.. literalinclude:: cli_library/017.php
185
-
:lines: 2-
186
170
187
171
Would create something like this:
188
172
@@ -200,7 +184,6 @@ Would create something like this:
200
184
The ``newLine()`` method displays a blank line to the user. It does not take any parameters:
201
185
202
186
.. literalinclude:: cli_library/018.php
203
-
:lines: 2-
204
187
205
188
**clearScreen()**
206
189
@@ -209,7 +192,6 @@ simply insert 40 blank lines since Windows doesn't support this feature. Windows
209
192
this:
210
193
211
194
.. literalinclude:: cli_library/019.php
212
-
:lines: 2-
213
195
214
196
**showProgress()**
215
197
@@ -227,12 +209,10 @@ The percent complete and the length of the display will be determined based on t
227
209
pass ``false`` as the first parameter and the progress bar will be removed.
228
210
229
211
.. literalinclude:: cli_library/020.php
230
-
:lines: 2-
231
212
232
213
**table()**
233
214
234
215
.. literalinclude:: cli_library/021.php
235
-
:lines: 2-
236
216
237
217
.. code-block:: none
238
218
@@ -249,4 +229,3 @@ Waits a certain number of seconds, optionally showing a wait message and
0 commit comments