pack: make the output arg optional

This way you can run:

  bam pack foobar.blend

.. which outputs foobar.zip
This commit is contained in:
2015-03-03 10:53:21 +11:00
parent 1111f24b04
commit fd51bbc4ba

View File

@@ -1625,12 +1625,20 @@ def create_argparse_pack(subparsers):
help="Pack a blend file and its dependencies into an archive", help="Pack a blend file and its dependencies into an archive",
description= description=
""" """
You can simply pack a blend file like this to create a zip-file of the same name.
.. code-block:: sh
bam pack /path/to/scene.blend
You may also want to give an explicit output directory.
This command is used for packing a ``.blend`` file into a ``.zip`` file for redistribution. This command is used for packing a ``.blend`` file into a ``.zip`` file for redistribution.
.. code-block:: sh .. code-block:: sh
# pack a blend with maximum compression for online downloads # pack a blend with maximum compression for online downloads
bam pack /path/to/scene.blend --output scene.zip --compress bam pack /path/to/scene.blend --output my_scene.zip --compress=best
""", """,
formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawDescriptionHelpFormatter,
) )
@@ -1639,7 +1647,7 @@ def create_argparse_pack(subparsers):
help="Path(s) to operate on", help="Path(s) to operate on",
) )
subparse.add_argument( subparse.add_argument(
"-o", "--output", dest="output", metavar='ZIP', required=True, "-o", "--output", dest="output", metavar='ZIP', required=False,
help="Output file or a directory when multiple inputs are passed", help="Output file or a directory when multiple inputs are passed",
) )
@@ -1649,7 +1657,7 @@ def create_argparse_pack(subparsers):
func=lambda args: func=lambda args:
bam_commands.pack( bam_commands.pack(
args.paths, args.paths,
args.output, args.output or (os.path.splitext(args.paths[0])[0] + ".zip"),
all_deps=args.all_deps, all_deps=args.all_deps,
use_quiet=args.use_quiet, use_quiet=args.use_quiet,
compress_level=args.compress_level), compress_level=args.compress_level),