Add --show-all flag to cymbol to list all custom structure names (#3157)

* Add --show-all flag to cymbol to list all custom structure names

* Fix: Apply ruff formatting to cymbol.py

* Fix: Regenerate cymbol docs for --show-all flag

---------

Co-authored-by: parrot <parrot@localhost.localdomain>
pull/3120/head^2
An0nAN4N7 5 months ago committed by GitHub
parent 0abe0a8066
commit 63812e0043
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,7 +4,7 @@
```text
usage: cymbol [-h] [-a name] [-f filepath] [-r name] [-e name] [-l name]
[-s name]
[-s name] [--show-all]
```
@ -20,6 +20,7 @@ Add, show, load, edit, or delete custom structures in plain C.
|-e|--edit|Edit an existing custom structure|
|-l|--load|Load an existing custom structure|
|-s|--show|Show the source code of an existing custom structure|
||--show-all|Show names of all available custom structures|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -301,10 +301,17 @@ parser.add_argument(
default=None,
type=str,
)
parser.add_argument(
"--show-all",
help="Show names of all available custom structures",
action="store_true",
)
@pwndbg.commands.Command(parser, category=CommandCategory.MISC)
def cymbol(add: str, file: str, remove: str, edit: str, load: str, show: str) -> None:
def cymbol(
add: str, file: str, remove: str, edit: str, load: str, show: str, show_all: bool
) -> None:
if add:
add_custom_structure(add)
elif file:
@ -317,5 +324,11 @@ def cymbol(add: str, file: str, remove: str, edit: str, load: str, show: str) ->
load_custom_structure(load)
elif show:
show_custom_structure(show)
elif show_all:
print(message.notice("Available custom structure names:\n"))
for file in os.listdir(pwndbg_cachedir):
if file.endswith(".c"):
name = os.path.splitext(file)[0]
print(f" - {name}")
else:
parser.print_help()

Loading…
Cancel
Save