diff --git a/.pylintrc b/.pylintrc index 9e75026..cb15f62 100644 --- a/.pylintrc +++ b/.pylintrc @@ -58,6 +58,7 @@ disable= fixme, invalid-name, missing-docstring, + no-value-for-parameter, protected-access, too-few-public-methods, diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..738bd51 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include version.py \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8828851 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ + +build: + rm -rf dist/ + python setup.py sdist + +push_test: + twine upload -r testpypi dist/*.tar.gz + +push_prod: + twine upload dist/*.tar.gz diff --git a/rfd/__init__.py b/rfd/__init__.py index e69de29..45b4acd 100644 --- a/rfd/__init__.py +++ b/rfd/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals + +__title__ = 'RFD CLI' +__author__ = 'Dave Gallant' +__license__ = 'Apache 2.0' +__copyright__ = '(c) 2018 Dave Gallant' diff --git a/rfd/__version__.py b/rfd/__version__.py new file mode 100644 index 0000000..29eea83 --- /dev/null +++ b/rfd/__version__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +__version__ = '0.0.7' diff --git a/rfd/rfd_cli.py b/rfd/rfd_cli.py index e021b2e..ad68cdd 100644 --- a/rfd/rfd_cli.py +++ b/rfd/rfd_cli.py @@ -1,13 +1,21 @@ +from __future__ import unicode_literals + + import sys import os import click from colorama import init, Fore, Style from rfd.api import get_threads, get_posts +from rfd.__version__ import __version__ init() print() +def get_version(): + return 'rfd ' + __version__ + + def get_terminal_width(): _, columns = os.popen('stty size', 'r').read().split() return int(columns) @@ -21,10 +29,20 @@ def get_vote_color(score): return Fore.BLUE + " [" + str(score) + "] " -@click.group() -def cli(): +@click.group(invoke_without_command=True) +@click.option('--version/--no-version', default=False) +@click.pass_context +def cli(ctx, version): """Welcome to the RFD CLI. (RedFlagDeals.com)""" - pass + if version: + click.echo(get_version()) + elif not ctx.invoked_subcommand: + click.echo(ctx.get_help()) + + +@cli.command('version') +def display_version(): + click.echo(get_version()) @cli.command(short_help="Displays posts in a specific thread.") @@ -71,7 +89,7 @@ def posts(post_id, head, tail): @cli.command(short_help="Displays threads in the specified forum.") -@click.option('--count', default=5, help='Number of topics.') +@click.option('--count', default=10, help='Number of topics.') @click.argument('forum_id') def threads(count, forum_id): """Displays threads in the specified forum id. diff --git a/setup.py b/setup.py index ab4b97c..40091fc 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ import io # for python2 from os import path from setuptools import setup +from version import __version__ as version here = path.abspath(path.dirname(__file__)) @@ -11,7 +12,7 @@ with io.open(path.join(here, 'README.rst'), encoding='utf-8') as f: setup( name='rfd', - version='0.0.6', + version=version, packages=['rfd'], keywords='cli redflagdeals', install_requires=[ diff --git a/version.py b/version.py new file mode 120000 index 0000000..324894e --- /dev/null +++ b/version.py @@ -0,0 +1 @@ +rfd/__version__.py \ No newline at end of file