Skip to content

Commit

Permalink
Refactor CLI to use console_scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kz26 committed Dec 9, 2016
1 parent 32114be commit c656e56
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changelog
* Add support for source strings (-s)
* Exclude hidden dotfiles from being added
* Exclude hidden files on Windows (requires Python 3.5+)
* Refactor - CLI tool is now simply `dottorrent`

1.5.3
-----
Expand Down
18 changes: 8 additions & 10 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
Command-line tool
=================

If you installed dottorrent using pip, ``dottorrent_cli`` should be
If you installed dottorrent using pip, ``dottorrent`` should be
available in your system path.

.. highlight:: none

::

usage: dottorrent_cli [-h] [--tracker TRACKER] [--web_seed WEB_SEED]
[--piece_size PIECE_SIZE] [--private]
[--comment COMMENT] [--date DATE] [--md5] [--verbose]
[--source SOURCE]
path output_path
usage: dottorrent [-h] [--tracker TRACKER] [--web_seed WEB_SEED]
[--piece_size PIECE_SIZE] [--private] [--source SOURCE]
[--comment COMMENT] [--date DATE] [--md5] [--verbose]
path output_path

Create a .torrent file

Expand All @@ -31,16 +30,15 @@ available in your system path.
--piece_size PIECE_SIZE, -s PIECE_SIZE
piece size in bytes
--private, -p set private flag
--source SOURCE source string (useful for private trackers)
--comment COMMENT, -c COMMENT
free-text string for the torrent comment field
string for the torrent comment field
--date DATE, -d DATE Torrent creation date. Valid values: unix
timestamp/none/now (default: now)
--md5 Add per-file MD5 hashes
--verbose, -v verbose mode
--source SOURCE

dottorrent/1.5.3 (https://github.com/kz26/dottorrent)

dottorrent/1.6.0 (https://github.com/kz26/dottorrent)


To add multiple trackers and/or web seeds, repeat the ``-t`` and ``-w`` as many times as necessary,
Expand Down
8 changes: 6 additions & 2 deletions bin/dottorrent_cli → dottorrent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import dottorrent


if __name__ == '__main__':
def main():
parser = argparse.ArgumentParser(description='Create a .torrent file',
epilog=dottorrent.DEFAULT_CREATOR)
parser.add_argument('--tracker', '-t', action='append', dest='trackers',
Expand All @@ -47,7 +47,7 @@
parser.add_argument(
'--private', '-p', action='store_true', help='set private flag')
parser.add_argument(
'--source', help='source string (useful for private trackers')
'--source', help='source string (useful for private trackers)')
parser.add_argument('--comment', '-c',
help='string for the torrent comment field')
parser.add_argument('--date', '-d', default='now',
Expand Down Expand Up @@ -131,3 +131,7 @@ def progress_callback(fn, pieces_completed, total_pieces):
t.save(f)
print("Info hash: " + t.info_hash)
print("Torrent file saved to {}".format(save_fn))


if __name__ == '__main__':
main()
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
name="dottorrent",
version=__version__,
packages=find_packages(),
scripts=['bin/dottorrent_cli'],
entry_points={
'console_scripts': [
'dottorrent = dottorrent.cli:main'
]
},

# Project uses reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
install_requires=['bencoder.pyx>=1.1.1,<2.0.0', 'humanfriendly>=2.1,<3.0', 'tqdm>=4.8.4,<5.0.0'],
install_requires=['bencoder.pyx>=1.1.1,<2.0.0',
'humanfriendly>=2.1,<3.0', 'tqdm>=4.8.4,<5.0.0'],

# metadata for upload to PyPI
author="Kevin Zhang",
Expand Down

0 comments on commit c656e56

Please sign in to comment.