diff --git a/pwndbg/commands/__init__.py b/pwndbg/commands/__init__.py index f5d767c55..55cb4d110 100644 --- a/pwndbg/commands/__init__.py +++ b/pwndbg/commands/__init__.py @@ -663,6 +663,7 @@ def load_commands() -> None: import pwndbg.commands.stack import pwndbg.commands.start import pwndbg.commands.telescope + import pwndbg.commands.tips import pwndbg.commands.tls import pwndbg.commands.valist import pwndbg.commands.version diff --git a/pwndbg/commands/tips.py b/pwndbg/commands/tips.py index 97632fbd7..4baed486e 100644 --- a/pwndbg/commands/tips.py +++ b/pwndbg/commands/tips.py @@ -1,11 +1,10 @@ from __future__ import annotations import argparse -import re import pwndbg.commands -from pwndbg.color import message from pwndbg.lib.tips import TIPS +from pwndbg.lib.tips import color_tip from pwndbg.lib.tips import get_tip_of_the_day parser = argparse.ArgumentParser(description="Shows tips.") @@ -16,10 +15,6 @@ parser.add_argument("--all", action="store_true", help="Show all tips.") def tips(all: bool) -> None: if all: for tip in TIPS: - print(__color_tip(tip)) + print(color_tip(tip)) else: - print(__color_tip(get_tip_of_the_day())) - - -def __color_tip(tip: str) -> str: - return re.sub("`(.*?)`", lambda s: message.warn(s.group()[1:-1]), tip) + print(color_tip(get_tip_of_the_day())) diff --git a/pwndbg/lib/tips.py b/pwndbg/lib/tips.py index 9db64d5ce..ebc7bb403 100644 --- a/pwndbg/lib/tips.py +++ b/pwndbg/lib/tips.py @@ -1,7 +1,10 @@ from __future__ import annotations +import re from random import choice +from pwndbg.color import message + TIPS: list[str] = [ # GDB hints "GDB's `apropos ` command displays all registered commands that are related to the given ", @@ -44,3 +47,7 @@ TIPS: list[str] = [ def get_tip_of_the_day() -> str: return choice(TIPS) + + +def color_tip(tip: str) -> str: + return re.sub("`(.*?)`", lambda s: message.warn(s.group()[1:-1]), tip)