Move color_tip function to separate module

pull/1857/head
Tomasz Kowalik 2 years ago committed by Disconnect3d
parent 940bdebaf2
commit eb637f3d15

@ -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

@ -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()))

@ -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 <topic>` command displays all registered commands that are related to the given <topic>",
@ -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)

Loading…
Cancel
Save