From 1de940d597f52d0669b8d8d5a1e736a19bf77855 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Mon, 16 Sep 2019 15:25:41 +0200 Subject: [PATCH] Enable --sort by default and add --no-sort to disable sorting In most cases the file order is not important and the unsorted output hurts readability. The performance impact of sorting is relatively small and barely noticeable even with large resource files. --- README.rst | 2 +- rsrcfork/__main__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index b63403f..17c9129 100644 --- a/README.rst +++ b/README.rst @@ -130,9 +130,9 @@ Changelog Version 1.2.1 (next version) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* Added a ``--sort`` command line option to output resources sorted by type and ID, instead of using the order stored in the file. * Added a ``--group`` command line option to group resources in list format by type (the default), ID, or with no grouping. * Added a ``dump-text`` output format to the command line tool. This format is identical to ``dump``, but instead of a hex dump, it outputs the resource data as text. The data is decoded as MacRoman and classic Mac newlines (``\r``) are translated. This is useful for examining resources that contain mostly plain text. +* Changed the command line tool to sort resources by type and ID, and added a ``--no-sort`` option to disable sorting and output resources in file order (which was the previous behavior). * Renamed the ``rsrcfork.Resource`` attributes ``resource_type`` and ``resource_id`` to ``type`` and ``id``, respectively. The old names have been deprecated and will be removed in the future, but are still supported for now. * Changed ``--format=dump`` output to match ``hexdump -C``'s format - spacing has been adjusted, and multiple subsequent identical lines are collapsed into a single ``*``. diff --git a/rsrcfork/__main__.py b/rsrcfork/__main__.py index bb64ab1..b93b91f 100644 --- a/rsrcfork/__main__.py +++ b/rsrcfork/__main__.py @@ -247,7 +247,7 @@ def _parse_args() -> argparse.Namespace: ap.add_argument("--no-decompress", action="store_false", dest="decompress", help="Do not decompress compressed resources, output compressed resource data as-is") ap.add_argument("--format", choices=["dump", "dump-text", "hex", "raw", "derez"], default="dump", help="How to output the resources - human-readable info with hex dump (dump) (default), human-readable info with newline-translated data (dump-text), data only as hex (hex), data only as raw bytes (raw), or like DeRez with no resource definitions (derez)") ap.add_argument("--group", action="store", choices=["none", "type", "id"], default="type", help="Group resources in list view by type or ID, or disable grouping (default: type)") - ap.add_argument("--sort", action="store_true", help="Output resources sorted by type and ID, instead of the order in which they are stored in the file") + ap.add_argument("--no-sort", action="store_false", dest="sort", help="Output resources in the order in which they are stored in the file, instead of sorting them by type and ID") ap.add_argument("--header-system", action="store_true", help="Output system-reserved header data and nothing else") ap.add_argument("--header-application", action="store_true", help="Output application-specific header data and nothing else")