Set default of threads command to 1 page and 40 threads (#80)

* Set default of threads command to 1 page and 40 threads

* Echo posts in a pager
This commit is contained in:
Dave Gallant
2020-08-16 15:07:48 -04:00
committed by GitHub
parent cfd7e01e43
commit b30a3c5b66
5 changed files with 52 additions and 51 deletions

View File

@@ -1,8 +1,32 @@
# pylint: disable=old-style-class
import os
from colorama import Fore, Style
from .scores import get_vote_color
class Post:
def __init__(self, body, score, user):
self.body = body
self.score = score
self.user = user
def get_terminal_width():
_, columns = os.popen("stty size", "r").read().split()
return int(columns)
def generate_posts_output(posts):
output = ""
output += ("-" * get_terminal_width())
for post in posts:
output += (
" -"
+ get_vote_color(post.score)
+ Fore.RESET
+ post.body
+ Fore.YELLOW
+ " ({})".format(post.user)
)
output += (Style.RESET_ALL)
output += "\n"
output += ("-" * get_terminal_width())
output += "\n"
return output