mirror of
https://github.com/davegallant/rfd.git
synced 2025-08-13 20:10:19 +00:00
@@ -28,9 +28,10 @@ def cli():
|
||||
|
||||
|
||||
@cli.command(short_help="Displays posts in a specific thread.")
|
||||
@click.option('--count', default=5, help='Number of topics. 0 for all topics')
|
||||
@click.option('--head', default=0, help='Number of topics. Default is 0, for all topics')
|
||||
@click.option('--tail', default=0, help='Number of topics. Default is disabled. This will override head.')
|
||||
@click.argument('post_id')
|
||||
def posts(count, post_id):
|
||||
def posts(post_id, head, tail):
|
||||
"""Displays posts in a specific thread.
|
||||
|
||||
post_id can be a full url or post id only
|
||||
@@ -41,13 +42,23 @@ def posts(count, post_id):
|
||||
url: https://forums.redflagdeals.com/koodo-targeted-public-mobile-12-120-koodo-5gb-40-no-referrals-2173603
|
||||
post_id: 2173603
|
||||
"""
|
||||
if count < 0:
|
||||
click.echo("Invalid count.")
|
||||
if head < 0:
|
||||
click.echo("Invalid head.")
|
||||
sys.exit(1)
|
||||
|
||||
if tail < 0:
|
||||
click.echo("Invalid tail.")
|
||||
sys.exit(1)
|
||||
|
||||
# Tail overrides head
|
||||
if tail > 0:
|
||||
count = tail
|
||||
else:
|
||||
count = head
|
||||
|
||||
try:
|
||||
click.echo("-" * get_terminal_width())
|
||||
for post in get_posts(post_id, count):
|
||||
for post in get_posts(post=post_id, count=count, tail=tail > 0):
|
||||
click.echo(" -" + get_vote_color(post.get('score')) + Fore.RESET +
|
||||
post.get('body') + Fore.YELLOW + " ({})".format(post.get('user')))
|
||||
click.echo(Style.RESET_ALL)
|
||||
|
Reference in New Issue
Block a user