Skip to content

Commit a1f127f

Browse files
committed
Add --expand option to control data truncation
Using this option, bytes data in panels will no longer be truncated.
1 parent 2f21855 commit a1f127f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/simple_safe/params.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@
2020

2121
optgroup = _OptGroup()
2222

23+
# Flags
2324
quiet_mode = False
25+
expand_data = False
2426

2527
# ┌───────────┐
2628
# │ Callbacks │
2729
# └───────────┘
2830

2931

32+
def expand_callback(
33+
ctx: click.Context, _: click.Option, value: Optional[bool]
34+
) -> Optional[Any]:
35+
if value:
36+
global expand_data
37+
expand_data = True
38+
return None
39+
40+
3041
def help_callback(
3142
ctx: click.Context, _: click.Option, value: Optional[bool]
3243
) -> Optional[Any]:
@@ -158,6 +169,14 @@ def build_safetx(f: FC) -> FC:
158169
def common(f: FC) -> FC:
159170
for option in reversed(
160171
[
172+
click.option(
173+
"--expand",
174+
is_flag=True,
175+
expose_value=False,
176+
is_eager=True,
177+
help="don't truncate data in panels",
178+
callback=expand_callback,
179+
),
161180
click.option(
162181
"-q",
163182
"--quiet",

src/simple_safe/util.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
HexBytes,
1414
)
1515

16+
from . import params
1617
from .chaindata import ChainData
1718
from .constants import (
1819
SAFE_SETUP_FUNC_SELECTOR,
@@ -142,7 +143,11 @@ def format_hexbytes(data: HexBytes) -> str:
142143
len_data = len(data)
143144
return (
144145
f"{data[:TRUNCATE_DATA_BYTES].to_0x_hex()}"
145-
+ ("[danger]...[/danger] " if len_data > TRUNCATE_DATA_BYTES else " ")
146+
+ (
147+
"[danger]...[/danger] "
148+
if (not params.expand_data and (len_data > TRUNCATE_DATA_BYTES))
149+
else " "
150+
)
146151
+ r"[secondary]\["
147152
+ f"{len_data:,} bytes][/secondary]"
148153
)

0 commit comments

Comments
 (0)