Skip to content

Commit

Permalink
support changing a tbf name (partially)
Browse files Browse the repository at this point in the history
name has to be the same number of characters
  • Loading branch information
bradjc committed Jun 19, 2024
1 parent a41b532 commit 02200af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tockloader/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ def plural(value):
return "s"


def number_or(value):
"""
Try to format value as a number. If that fails, just leave it alone.
"""
try:
return int(value, 0)
except:
return value


def text_in_box(string, box_width, box_height=3):
"""
Return a string like:
Expand Down
2 changes: 1 addition & 1 deletion tockloader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ def main():
)
tbf_tlv_modify.add_argument("field", help="TLV field name")
tbf_tlv_modify.add_argument(
"value", help="TLV field new value", type=lambda x: int(x, 0)
"value", help="TLV field new value", type=helpers.number_or
)
tbf_tlv_modify.add_argument("tab", help="The TAB or TABs to modify", nargs="*")

Expand Down

0 comments on commit 02200af

Please sign in to comment.