Skip to content

Commit

Permalink
objective_c_symbol: Add dump option to show
Browse files Browse the repository at this point in the history
  • Loading branch information
Netanel Cohen committed Jun 29, 2023
1 parent 95a45ab commit fb5c306
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/rpcclient/rpcclient/darwin/objective_c_symbol.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
from contextlib import suppress
from dataclasses import dataclass
from functools import partial
from pathlib import Path
from typing import Optional

from pygments import highlight
from pygments.formatters import TerminalTrueColorFormatter
Expand Down Expand Up @@ -76,12 +79,19 @@ def reload(self):
self.properties = properties_list
self.class_ = class_wrapper

def show(self, recursive: bool = False):
def show(self, dump_to: Optional[str] = None, recursive: bool = False):
"""
Print to terminal the highlighted class description.
:param dump_to: directory to dump.
:param recursive: Show methods of super classes.
"""
print(highlight(self._to_str(recursive), ObjectiveCLexer(), TerminalTrueColorFormatter(style='native')))
formatted = self._to_str(recursive)
print(highlight(formatted, ObjectiveCLexer(), TerminalTrueColorFormatter(style='native')))

if not dump_to:
return
fn = (Path(dump_to) / f'{self.class_.name}.m').expanduser()
fn.write_text(formatted)

def objc_call(self, selector: str, *params, **kwargs):
"""
Expand Down

0 comments on commit fb5c306

Please sign in to comment.