Add a setuptools entry point for the command-line interface

This commit is contained in:
dgelessus 2019-07-14 01:23:08 +02:00
parent 9dfb33f436
commit 6247013592
3 changed files with 8 additions and 3 deletions

View File

@ -120,6 +120,7 @@ Changelog
(next version)
^^^^^^^^^^^^^^
* Added a setuptools entry point for the command-line interface. This allows calling it using just ``rsrcfork`` instead of ``python3 -m rsrcfork``.
* Changed the default value of ``ResourceFork.__init__``'s ``close`` keyword argument from ``True`` to ``False``. This matches the behavior of classes like ``zipfile.ZipFile`` and ``tarfile.TarFile``.
* Fixed ``ResourceFork.open`` and ``ResourceFork.__init__`` not closing their streams in some cases.
* Refactored the single ``rsrcfork.py`` file into a package. This is an internal change and should have no effect on how the ``rsrcfork`` module is used.

View File

@ -160,7 +160,7 @@ def _raw_hexdump(data: bytes):
for i in range(0, len(data), 16):
print(" ".join(f"{byte:02x}" for byte in data[i:i + 16]))
def main(args: typing.Sequence[str]):
def main():
ap = argparse.ArgumentParser(
add_help=False,
fromfile_prefix_chars="@",
@ -194,7 +194,7 @@ def main(args: typing.Sequence[str]):
ap.add_argument("file", help="The file to read, or - for stdin")
ap.add_argument("filter", nargs="*", help="One or more filters to select which resources to display, or omit to show an overview of all resources")
ns = ap.parse_args(args)
ns = ap.parse_args()
ns.fork = {"auto": None, "data": False, "rsrc": True}[ns.fork]
ns.read_mode = {"auto": None, "stream": False, "seek": True}[ns.read_mode]
@ -348,4 +348,4 @@ def main(args: typing.Sequence[str]):
sys.exit(0)
if __name__ == "__main__":
main(sys.argv[1:])
sys.exit(main())

View File

@ -34,3 +34,7 @@ setup_requires =
python_requires = >=3.6
packages =
rsrcfork
[options.entry_points]
console_scripts =
rsrcfork = rsrcfork.__main__:main