Skip to content

Commit 35d13a5

Browse files
committed
Add support for table folding via an env var
'GLOBUS_CLI_FOLD_TABLES=1' enables table folding for all tabular outputs. This can be used to preview the behavior and, in the future, to opt-out of folded table output for the entire CLI.
1 parent 53fd961 commit 35d13a5

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/globus_cli/termio/_display.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
import click
77
import globus_sdk
88

9-
from .context import outformat_is_json, outformat_is_text, outformat_is_unix
9+
from .context import (
10+
fold_tables,
11+
outformat_is_json,
12+
outformat_is_text,
13+
outformat_is_unix,
14+
)
1015
from .field import Field
1116
from .printers import (
1217
CustomPrinter,
@@ -25,7 +30,6 @@ class TextMode(enum.Enum):
2530
silent = enum.auto()
2631
json = enum.auto()
2732
text_table = enum.auto()
28-
text_folded_table = enum.auto()
2933
text_record = enum.auto()
3034
text_record_list = enum.auto()
3135
text_raw = enum.auto()
@@ -42,7 +46,6 @@ class Renderer:
4246
"""
4347

4448
TABLE = TextMode.text_table
45-
FOLDED_TABLE = TextMode.text_folded_table
4649
SILENT = TextMode.silent
4750
JSON = TextMode.json
4851
RECORD = TextMode.text_record
@@ -168,16 +171,17 @@ def _resolve_printer(
168171
if not isinstance(text_mode, TextMode):
169172
return CustomPrinter(custom_print=text_mode)
170173

171-
if text_mode in (self.FOLDED_TABLE, self.TABLE, self.RECORD, self.RECORD_LIST):
174+
if text_mode in (self.TABLE, self.RECORD, self.RECORD_LIST):
172175
fields = _assert_fields(fields)
173176
if text_mode == self.RECORD:
174177
return RecordPrinter(fields)
175178

176179
_assert_iterable(data)
177180
if text_mode == self.TABLE:
178-
return TablePrinter(fields)
179-
if text_mode == self.FOLDED_TABLE:
180-
return FoldedTablePrinter(fields)
181+
if fold_tables():
182+
return FoldedTablePrinter(fields)
183+
else:
184+
return TablePrinter(fields)
181185
if text_mode == self.RECORD_LIST:
182186
return RecordListPrinter(fields)
183187

src/globus_cli/termio/context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,8 @@ def term_is_interactive() -> bool:
108108
return True
109109

110110
return os.getenv("PS1") is not None
111+
112+
113+
def fold_tables() -> bool | None:
114+
val = os.getenv("GLOBUS_CLI_FOLD_TABLES")
115+
return val is not None and utils.str2bool(val)

0 commit comments

Comments
 (0)