A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 02:15 UTC
[frontend] Add --help=page option for paginated help output (#20961)
Signed-off-by: reidliu41 <reid201711@gmail.com>
Reid committed
Jul 15, 2025 at 15:42 UTC
68d28e37b0d3706601b0d5231178cebaad032605
2 files changed
+39
-8
docs/cli/README.md
+3
@@ -37,6 +37,9 @@ Start the vLLM OpenAI Compatible API server.
37
38
# To search by keyword
39
vllm serve --help=max
40
+
41
+ # To view full help with pager (less/more)
42
+ vllm serve --help=page
43
```
44
45
## chat
vllm/entrypoints/utils.py
+36
-8
@@ -5,6 +5,7 @@ import argparse
5
import asyncio
6
import functools
7
import os
8
+import subprocess
9
import sys
10
from typing import Any, Optional, Union
11
@@ -25,7 +26,8 @@ VLLM_SUBCMD_PARSER_EPILOG = (
26
" - To view a argument group: --help=ModelConfig\n"
27
" - To view a single argument: --help=max-num-seqs\n"
28
" - To search by keyword: --help=max\n"
28
- " - To list all groups: --help=listgroup")
29
+ " - To list all groups: --help=listgroup\n"
30
+ " - To view help with pager: --help=page")
31
32
33
async def listen_for_disconnect(request: Request) -> None:
@@ -190,6 +192,24 @@ def _validate_truncation_size(
192
return truncate_prompt_tokens
193
194
195
+def _output_with_pager(text: str):
196
+ """Output text using scrolling view if available and appropriate."""
197
+
198
+ pagers = ['less -R', 'more']
199
+ for pager_cmd in pagers:
200
+ try:
201
+ proc = subprocess.Popen(pager_cmd.split(),
202
+ stdin=subprocess.PIPE,
203
+ text=True)
204
+ proc.communicate(input=text)
205
+ return
206
+ except (subprocess.SubprocessError, OSError, FileNotFoundError):
207
+ continue
208
+
209
+ # No pager worked, fall back to normal print
210
+ print(text)
211
+
212
+
213
def show_filtered_argument_or_group_from_help(parser: argparse.ArgumentParser,
214
subcommand_name: list[str]):
215
@@ -208,16 +228,24 @@ def show_filtered_argument_or_group_from_help(parser: argparse.ArgumentParser,
228
if arg.startswith('--help='):
229
search_keyword = arg.split('=', 1)[1]
230
231
+ # Enable paged view for full help
232
+ if search_keyword == 'page':
233
+ help_text = parser.format_help()
234
+ _output_with_pager(help_text)
235
+ sys.exit(0)
236
+
237
# List available groups
238
if search_keyword == 'listgroup':
213
- print("\nAvailable argument groups:")
239
+ output_lines = ["\nAvailable argument groups:"]
240
for group in parser._action_groups:
241
if group.title and not group.title.startswith(
242
"positional arguments"):
217
- print(f" - {group.title}")
243
+ output_lines.append(f" - {group.title}")
244
if group.description:
219
- print(" " + group.description.strip())
220
- print()
245
+ output_lines.append(" " +
246
+ group.description.strip())
247
+ output_lines.append("")
248
+ _output_with_pager("\n".join(output_lines))
249
sys.exit(0)
250
251
# For group search
@@ -229,7 +257,7 @@ def show_filtered_argument_or_group_from_help(parser: argparse.ArgumentParser,
257
formatter.add_text(group.description)
258
formatter.add_arguments(group._group_actions)
259
formatter.end_section()
232
- print(formatter.format_help())
260
+ _output_with_pager(formatter.format_help())
261
sys.exit(0)
262
263
# For single arg
@@ -243,10 +271,10 @@ def show_filtered_argument_or_group_from_help(parser: argparse.ArgumentParser,
271
matched_actions.append(action)
272
273
if matched_actions:
246
- print(f"\nParameters matching '{search_keyword}':\n")
274
+ header = f"\nParameters matching '{search_keyword}':\n"
275
formatter = parser._get_formatter()
276
formatter.add_arguments(matched_actions)
249
- print(formatter.format_help())
277
+ _output_with_pager(header + formatter.format_help())
278
sys.exit(0)
279
280
print(f"\nNo group or parameter matching '{search_keyword}'")