From fd51bbc4ba9fab3b8b00decc3c342547b51b69c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Mar 2015 10:53:21 +1100 Subject: [PATCH] pack: make the output arg optional This way you can run: bam pack foobar.blend .. which outputs foobar.zip --- bam/cli.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bam/cli.py b/bam/cli.py index a2f5ca4..ac33bc5 100755 --- a/bam/cli.py +++ b/bam/cli.py @@ -1625,12 +1625,20 @@ def create_argparse_pack(subparsers): help="Pack a blend file and its dependencies into an archive", 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. .. code-block:: sh # 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, ) @@ -1639,7 +1647,7 @@ def create_argparse_pack(subparsers): help="Path(s) to operate on", ) 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", ) @@ -1649,7 +1657,7 @@ def create_argparse_pack(subparsers): func=lambda args: bam_commands.pack( args.paths, - args.output, + args.output or (os.path.splitext(args.paths[0])[0] + ".zip"), all_deps=args.all_deps, use_quiet=args.use_quiet, compress_level=args.compress_level),