Skip to content

Commit f8e7cb2

Browse files
committed
minor #18740 [Console] Mention SymfonyStyle in helpers doc (HeahDude)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] Mention `SymfonyStyle` in helpers doc Commits ------- e98545b [Console] Mention `SymfonyStyle` in helpers doc
2 parents d2cdcf0 + e98545b commit f8e7cb2

File tree

5 files changed

+53
-24
lines changed

5 files changed

+53
-24
lines changed

components/console/helpers/formatterhelper.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ in the default helper set and you can get it by calling
1313

1414
The methods return a string, which you'll usually render to the console by
1515
passing it to the
16-
:method:`OutputInterface::writeln <Symfony\\Component\\Console\\Output\\OutputInterface::writeln>` method.
16+
:method:`OutputInterface::writeln <Symfony\\Component\\Console\\Output\\OutputInterface::writeln>`
17+
method.
18+
19+
.. note::
20+
21+
As an alternative, consider using the
22+
:ref:`SymfonyStyle <symfony-style-blocks>` to display stylized blocks.
1723

1824
Print Messages in a Section
1925
---------------------------

components/console/helpers/progressbar.rst

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ information, which updates as your command runs:
66

77
.. image:: /_images/components/console/progressbar.gif
88

9+
.. note::
10+
11+
As an alternative, consider using the
12+
:ref:`SymfonyStyle <symfony-style-progressbar>` to display a progress bar.
13+
914
To display progress details, use the
1015
:class:`Symfony\\Component\\Console\\Helper\\ProgressBar`, pass it a total
1116
number of units, and advance the progress as the command executes::

components/console/helpers/questionhelper.rst

+26-21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ first argument, an :class:`Symfony\\Component\\Console\\Output\\OutputInterface`
1515
instance as the second argument and a
1616
:class:`Symfony\\Component\\Console\\Question\\Question` as last argument.
1717

18+
.. note::
19+
20+
As an alternative, consider using the
21+
:ref:`SymfonyStyle <symfony-style-questions>` to ask questions.
22+
1823
Asking the User for Confirmation
1924
--------------------------------
2025

@@ -82,9 +87,9 @@ if you want to know a bundle name, you can add this to your command::
8287
$question = new Question('Please enter the name of the bundle', 'AcmeDemoBundle');
8388

8489
$bundleName = $helper->ask($input, $output, $question);
85-
90+
8691
// ... do something with the bundleName
87-
92+
8893
return Command::SUCCESS;
8994
}
9095

@@ -120,7 +125,7 @@ from a predefined list::
120125
$output->writeln('You have just selected: '.$color);
121126

122127
// ... do something with the color
123-
128+
124129
return Command::SUCCESS;
125130
}
126131

@@ -162,7 +167,7 @@ this use :method:`Symfony\\Component\\Console\\Question\\ChoiceQuestion::setMult
162167

163168
$colors = $helper->ask($input, $output, $question);
164169
$output->writeln('You have just selected: ' . implode(', ', $colors));
165-
170+
166171
return Command::SUCCESS;
167172
}
168173

@@ -191,9 +196,9 @@ will be autocompleted as the user types::
191196
$question->setAutocompleterValues($bundles);
192197

193198
$bundleName = $helper->ask($input, $output, $question);
194-
199+
195200
// ... do something with the bundleName
196-
201+
197202
return Command::SUCCESS;
198203
}
199204

@@ -230,9 +235,9 @@ provide a callback function to dynamically generate suggestions::
230235
$question->setAutocompleterCallback($callback);
231236

232237
$filePath = $helper->ask($input, $output, $question);
233-
238+
234239
// ... do something with the filePath
235-
240+
236241
return Command::SUCCESS;
237242
}
238243

@@ -254,9 +259,9 @@ You can also specify if you want to not trim the answer by setting it directly w
254259
$question->setTrimmable(false);
255260
// if the users inputs 'elsa ' it will not be trimmed and you will get 'elsa ' as value
256261
$name = $helper->ask($input, $output, $question);
257-
262+
258263
// ... do something with the name
259-
264+
260265
return Command::SUCCESS;
261266
}
262267

@@ -285,9 +290,9 @@ the response to a question should allow multiline answers by passing ``true`` to
285290
$question->setMultiline(true);
286291

287292
$answer = $helper->ask($input, $output, $question);
288-
293+
289294
// ... do something with the answer
290-
295+
291296
return Command::SUCCESS;
292297
}
293298

@@ -313,9 +318,9 @@ convenient for passwords::
313318
$question->setHiddenFallback(false);
314319

315320
$password = $helper->ask($input, $output, $question);
316-
321+
317322
// ... do something with the password
318-
323+
319324
return Command::SUCCESS;
320325
}
321326

@@ -347,7 +352,7 @@ convenient for passwords::
347352
QuestionHelper::disableStty();
348353

349354
// ...
350-
355+
351356
return Command::SUCCESS;
352357
}
353358

@@ -376,9 +381,9 @@ method::
376381
});
377382

378383
$bundleName = $helper->ask($input, $output, $question);
379-
384+
380385
// ... do something with the bundleName
381-
386+
382387
return Command::SUCCESS;
383388
}
384389

@@ -420,9 +425,9 @@ method::
420425
$question->setMaxAttempts(2);
421426

422427
$bundleName = $helper->ask($input, $output, $question);
423-
428+
424429
// ... do something with the bundleName
425-
430+
426431
return Command::SUCCESS;
427432
}
428433

@@ -482,9 +487,9 @@ You can also use a validator with a hidden question::
482487
$question->setMaxAttempts(20);
483488

484489
$password = $helper->ask($input, $output, $question);
485-
490+
486491
// ... do something with the password
487-
492+
488493
return Command::SUCCESS;
489494
}
490495

components/console/helpers/table.rst

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ When building a console application it may be useful to display tabular data:
1414
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
1515
+---------------+--------------------------+------------------+
1616
17+
.. note::
18+
19+
As an alternative, consider using the
20+
:ref:`SymfonyStyle <symfony-style-content>` to display a table.
21+
1722
To display a table, use :class:`Symfony\\Component\\Console\\Helper\\Table`,
1823
set the headers, set the rows and then render the table::
1924

@@ -38,7 +43,7 @@ set the headers, set the rows and then render the table::
3843
])
3944
;
4045
$table->render();
41-
46+
4247
return Command::SUCCESS;
4348
}
4449
}
@@ -414,7 +419,7 @@ The only requirement to append rows is that the table must be rendered inside a
414419
$table->render();
415420

416421
$table->appendRow(['Symfony']);
417-
422+
418423
return Command::SUCCESS;
419424
}
420425
}

console/style.rst

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ Titling Methods
9696

9797
// ...
9898

99+
.. _symfony-style-content:
100+
99101
Content Methods
100102
~~~~~~~~~~~~~~~
101103

@@ -219,6 +221,8 @@ Admonition Methods
219221
'Aenean sit amet arcu vitae sem faucibus porta',
220222
]);
221223

224+
.. _symfony-style-progressbar:
225+
222226
Progress Bar Methods
223227
~~~~~~~~~~~~~~~~~~~~
224228

@@ -267,6 +271,8 @@ Progress Bar Methods
267271
Creates an instance of :class:`Symfony\\Component\\Console\\Helper\\ProgressBar`
268272
styled according to the Symfony Style Guide.
269273

274+
.. _symfony-style-questions:
275+
270276
User Input Methods
271277
~~~~~~~~~~~~~~~~~~
272278

@@ -329,6 +335,8 @@ User Input Methods
329335

330336
$io->choice('Select the queue to analyze', ['queue1', 'queue2', 'queue3'], 'queue1');
331337

338+
.. _symfony-style-blocks:
339+
332340
Result Methods
333341
~~~~~~~~~~~~~~
334342

0 commit comments

Comments
 (0)