mirror of
https://github.com/davegallant/rfd.git
synced 2025-08-06 08:43:41 +00:00
Feature/display version (#2)
* --version and version displays the version
This commit is contained in:
@@ -58,6 +58,7 @@ disable=
|
|||||||
fixme,
|
fixme,
|
||||||
invalid-name,
|
invalid-name,
|
||||||
missing-docstring,
|
missing-docstring,
|
||||||
|
no-value-for-parameter,
|
||||||
protected-access,
|
protected-access,
|
||||||
too-few-public-methods,
|
too-few-public-methods,
|
||||||
|
|
||||||
|
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include version.py
|
10
Makefile
Normal file
10
Makefile
Normal file
@@ -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
|
@@ -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'
|
||||||
|
4
rfd/__version__.py
Normal file
4
rfd/__version__.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
__version__ = '0.0.7'
|
@@ -1,13 +1,21 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import click
|
import click
|
||||||
from colorama import init, Fore, Style
|
from colorama import init, Fore, Style
|
||||||
from rfd.api import get_threads, get_posts
|
from rfd.api import get_threads, get_posts
|
||||||
|
from rfd.__version__ import __version__
|
||||||
|
|
||||||
init()
|
init()
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
return 'rfd ' + __version__
|
||||||
|
|
||||||
|
|
||||||
def get_terminal_width():
|
def get_terminal_width():
|
||||||
_, columns = os.popen('stty size', 'r').read().split()
|
_, columns = os.popen('stty size', 'r').read().split()
|
||||||
return int(columns)
|
return int(columns)
|
||||||
@@ -21,10 +29,20 @@ def get_vote_color(score):
|
|||||||
return Fore.BLUE + " [" + str(score) + "] "
|
return Fore.BLUE + " [" + str(score) + "] "
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group(invoke_without_command=True)
|
||||||
def cli():
|
@click.option('--version/--no-version', default=False)
|
||||||
|
@click.pass_context
|
||||||
|
def cli(ctx, version):
|
||||||
"""Welcome to the RFD CLI. (RedFlagDeals.com)"""
|
"""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.")
|
@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.")
|
@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')
|
@click.argument('forum_id')
|
||||||
def threads(count, forum_id):
|
def threads(count, forum_id):
|
||||||
"""Displays threads in the specified forum id.
|
"""Displays threads in the specified forum id.
|
||||||
|
3
setup.py
3
setup.py
@@ -1,6 +1,7 @@
|
|||||||
import io # for python2
|
import io # for python2
|
||||||
from os import path
|
from os import path
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
from version import __version__ as version
|
||||||
|
|
||||||
|
|
||||||
here = path.abspath(path.dirname(__file__))
|
here = path.abspath(path.dirname(__file__))
|
||||||
@@ -11,7 +12,7 @@ with io.open(path.join(here, 'README.rst'), encoding='utf-8') as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='rfd',
|
name='rfd',
|
||||||
version='0.0.6',
|
version=version,
|
||||||
packages=['rfd'],
|
packages=['rfd'],
|
||||||
keywords='cli redflagdeals',
|
keywords='cli redflagdeals',
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
1
version.py
Symbolic link
1
version.py
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
rfd/__version__.py
|
Reference in New Issue
Block a user