@@ -1260,19 +1260,7 @@ def poutput(
1260
1260
) -> None :
1261
1261
"""Print objects to self.stdout.
1262
1262
1263
- :param objects: objects to print
1264
- :param sep: string to write between print data. Defaults to " ".
1265
- :param end: string to write at end of print data. Defaults to a newline.
1266
- :param style: optional style to apply to output
1267
- :param soft_wrap: Enable soft wrap mode. If True, text lines will not be automatically word-wrapped to fit the
1268
- terminal width; instead, any text that doesn't fit will run onto the following line(s),
1269
- similar to the built-in print() function. Set to False to enable automatic word-wrapping.
1270
- If None (the default for this parameter), the output will default to no word-wrapping, as
1271
- configured by the Cmd2GeneralConsole.
1272
- :param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
1273
- :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
1274
- method and still call `super()` without encountering unexpected keyword argument errors.
1275
- These arguments are not passed to Rich's Console.print().
1263
+ For details on the parameters, refer to the `print_to` method documentation.
1276
1264
"""
1277
1265
self .print_to (
1278
1266
self .stdout ,
@@ -1296,19 +1284,9 @@ def perror(
1296
1284
) -> None :
1297
1285
"""Print objects to sys.stderr.
1298
1286
1299
- :param objects: objects to print
1300
- :param sep: string to write between print data. Defaults to " ".
1301
- :param end: string to write at end of print data. Defaults to a newline.
1302
1287
:param style: optional style to apply to output. Defaults to Cmd2Style.ERROR.
1303
- :param soft_wrap: Enable soft wrap mode. If True, text lines will not be automatically word-wrapped to fit the
1304
- terminal width; instead, any text that doesn't fit will run onto the following line(s),
1305
- similar to the built-in print() function. Set to False to enable automatic word-wrapping.
1306
- If None (the default for this parameter), the output will default to no word-wrapping, as
1307
- configured by the Cmd2GeneralConsole.
1308
- :param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
1309
- :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
1310
- method and still call `super()` without encountering unexpected keyword argument errors.
1311
- These arguments are not passed to Rich's Console.print().
1288
+
1289
+ For details on the other parameters, refer to the `print_to` method documentation.
1312
1290
"""
1313
1291
self .print_to (
1314
1292
sys .stderr ,
@@ -1331,18 +1309,7 @@ def psuccess(
1331
1309
) -> None :
1332
1310
"""Wrap poutput, but apply Cmd2Style.SUCCESS.
1333
1311
1334
- :param objects: objects to print
1335
- :param sep: string to write between print data. Defaults to " ".
1336
- :param end: string to write at end of print data. Defaults to a newline.
1337
- :param soft_wrap: Enable soft wrap mode. If True, text lines will not be automatically word-wrapped to fit the
1338
- terminal width; instead, any text that doesn't fit will run onto the following line(s),
1339
- similar to the built-in print() function. Set to False to enable automatic word-wrapping.
1340
- If None (the default for this parameter), the output will default to no word-wrapping, as
1341
- configured by the Cmd2GeneralConsole.
1342
- :param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
1343
- :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
1344
- method and still call `super()` without encountering unexpected keyword argument errors.
1345
- These arguments are not passed to Rich's Console.print().
1312
+ For details on the parameters, refer to the `print_to` method documentation.
1346
1313
"""
1347
1314
self .poutput (
1348
1315
* objects ,
@@ -1364,18 +1331,7 @@ def pwarning(
1364
1331
) -> None :
1365
1332
"""Wrap perror, but apply Cmd2Style.WARNING.
1366
1333
1367
- :param objects: objects to print
1368
- :param sep: string to write between print data. Defaults to " ".
1369
- :param end: string to write at end of print data. Defaults to a newline.
1370
- :param soft_wrap: Enable soft wrap mode. If True, text lines will not be automatically word-wrapped to fit the
1371
- terminal width; instead, any text that doesn't fit will run onto the following line(s),
1372
- similar to the built-in print() function. Set to False to enable automatic word-wrapping.
1373
- If None (the default for this parameter), the output will default to no word-wrapping, as
1374
- configured by the Cmd2GeneralConsole.
1375
- :param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
1376
- :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
1377
- method and still call `super()` without encountering unexpected keyword argument errors.
1378
- These arguments are not passed to Rich's Console.print().
1334
+ For details on the parameters, refer to the `print_to` method documentation.
1379
1335
"""
1380
1336
self .perror (
1381
1337
* objects ,
@@ -1393,20 +1349,19 @@ def pexcept(
1393
1349
rich_print_kwargs : RichPrintKwargs | None = None ,
1394
1350
** kwargs : Any , # noqa: ARG002
1395
1351
) -> None :
1396
- """Print exception to sys.stderr. If debug is true, print exception traceback if one exists .
1352
+ """Print an exception to sys.stderr.
1397
1353
1398
- :param exception: the exception to print.
1399
- :param end: string to write at end of print data. Defaults to a newline.
1400
- :param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
1401
- :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
1402
- method and still call `super()` without encountering unexpected keyword argument errors.
1403
- These arguments are not passed to Rich's Console.print().
1354
+ If `debug` is true, a full exception traceback is also printed, if one exists.
1355
+
1356
+ :param exception: the exception to be printed.
1357
+
1358
+ For details on the other parameters, refer to the `print_to` method documentation.
1404
1359
"""
1405
1360
final_msg = Text ()
1406
1361
1407
1362
if self .debug and sys .exc_info () != (None , None , None ):
1408
1363
console = Cmd2GeneralConsole (sys .stderr )
1409
- console .print_exception (word_wrap = True )
1364
+ console .print_exception (word_wrap = True , max_frames = 0 )
1410
1365
else :
1411
1366
final_msg += f"EXCEPTION of type '{ type (exception ).__name__ } ' occurred with message: { exception } "
1412
1367
@@ -1431,23 +1386,12 @@ def pfeedback(
1431
1386
rich_print_kwargs : RichPrintKwargs | None = None ,
1432
1387
** kwargs : Any , # noqa: ARG002
1433
1388
) -> None :
1434
- """For printing nonessential feedback. Can be silenced with `quiet` .
1389
+ """Print nonessential feedback.
1435
1390
1436
- Inclusion in redirected output is controlled by `feedback_to_output`.
1391
+ The output can be silenced with the `quiet` setting and its inclusion in redirected output
1392
+ is controlled by the `feedback_to_output` setting.
1437
1393
1438
- :param objects: objects to print
1439
- :param sep: string to write between print data. Defaults to " ".
1440
- :param end: string to write at end of print data. Defaults to a newline.
1441
- :param style: optional style to apply to output
1442
- :param soft_wrap: Enable soft wrap mode. If True, text lines will not be automatically word-wrapped to fit the
1443
- terminal width; instead, any text that doesn't fit will run onto the following line(s),
1444
- similar to the built-in print() function. Set to False to enable automatic word-wrapping.
1445
- If None (the default for this parameter), the output will default to no word-wrapping, as
1446
- configured by the Cmd2GeneralConsole.
1447
- :param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
1448
- :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
1449
- method and still call `super()` without encountering unexpected keyword argument errors.
1450
- These arguments are not passed to Rich's Console.print().
1394
+ For details on the parameters, refer to the `print_to` method documentation.
1451
1395
"""
1452
1396
if not self .quiet :
1453
1397
if self .feedback_to_output :
@@ -1480,15 +1424,12 @@ def ppaged(
1480
1424
rich_print_kwargs : RichPrintKwargs | None = None ,
1481
1425
** kwargs : Any , # noqa: ARG002
1482
1426
) -> None :
1483
- """Print output using a pager if it would go off screen and stdout isn't currently being redirected .
1427
+ """Print output using a pager.
1484
1428
1485
- Never uses a pager inside a script (Python or text) or when output is being redirected or piped or when
1486
- stdout or stdin are not a fully functional terminal.
1429
+ A pager is used when the terminal is interactive and may exit immediately if the output
1430
+ fits on the screen. A pager is not used inside a script (Python or text) or when output is
1431
+ redirected or piped, and in these cases, output is sent to `poutput`.
1487
1432
1488
- :param objects: objects to print
1489
- :param sep: string to write between print data. Defaults to " ".
1490
- :param end: string to write at end of print data. Defaults to a newline.
1491
- :param style: optional style to apply to output
1492
1433
:param chop: True -> causes lines longer than the screen width to be chopped (truncated) rather than wrapped
1493
1434
- truncated text is still accessible by scrolling with the right & left arrow keys
1494
1435
- chopping is ideal for displaying wide tabular data as is done in utilities like pgcli
@@ -1500,13 +1441,12 @@ def ppaged(
1500
1441
similar to the built-in print() function. Set to False to enable automatic word-wrapping.
1501
1442
If None (the default for this parameter), the output will default to no word-wrapping, as
1502
1443
configured by the Cmd2GeneralConsole.
1444
+
1503
1445
Note: If chop is True and a pager is used, soft_wrap is automatically set to True.
1504
- :param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
1505
- :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
1506
- method and still call `super()` without encountering unexpected keyword argument errors.
1507
- These arguments are not passed to Rich's Console.print().
1446
+
1447
+ For details on the other parameters, refer to the `print_to` method documentation.
1508
1448
"""
1509
- # Detect if we are running within a fully functional terminal.
1449
+ # Detect if we are running within an interactive terminal.
1510
1450
# Don't try to use the pager when being run by a continuous integration system like Jenkins + pexpect.
1511
1451
functional_terminal = (
1512
1452
self .stdin .isatty ()
0 commit comments