LibraryOfCongress / bagit-python

Work with BagIt packages from Python.
http://libraryofcongress.github.io/bagit-python
218 stars 85 forks source link

Fix CLI for bagging multiple directories #89

Closed acdha closed 7 years ago

acdha commented 7 years ago

This change makes the promised bagit.py dir1 dir2 actually work and updates the help text.

johnscancella commented 7 years ago

LGTM

acdha commented 7 years ago

I just added more help updates. Here's what --help looked like with 1.5.4:

Usage: bagit.py [options] dir1 dir2 ...

Options:
  -h, --help            show this help message and exit
  --processes=PROCESSES
                        parallelize checksums generation and verification
  --log=LOG             
  --quiet               
  --validate            
  --fast                
  --md5                 Generate MD5 manifest when creating a bag (default)
  --sha1                Generate SHA1 manifest when creating a bag
  --sha256              Generate SHA-256 manifest when creating a bag
  --sha512              Generate SHA-512 manifest when creating a bag
  --source-organization=SOURCE_ORGANIZATION
  --organization-address=ORGANIZATION_ADDRESS
  --contact-name=CONTACT_NAME
  --contact-phone=CONTACT_PHONE
  --contact-email=CONTACT_EMAIL
  --external-description=EXTERNAL_DESCRIPTION
  --external-identifier=EXTERNAL_IDENTIFIER
  --bag-size=BAG_SIZE   
  --bag-group-identifier=BAG_GROUP_IDENTIFIER
  --bag-count=BAG_COUNT
  --internal-sender-identifier=INTERNAL_SENDER_IDENTIFIER
  --internal-sender-description=INTERNAL_SENDER_DESCRIPTION
  --bagit-profile-identifier=BAGIT_PROFILE_IDENTIFIER

Here's what it looks like after the proposed changes:

usage: bagit.py [-h] [--processes PROCESSES] [--log LOG] [--quiet]
                [--validate] [--fast] [--sha1] [--sha224] [--sha384]
                [--sha256] [--sha512] [--md5]
                [--source-organization SOURCE_ORGANIZATION]
                [--organization-address ORGANIZATION_ADDRESS]
                [--contact-name CONTACT_NAME] [--contact-phone CONTACT_PHONE]
                [--contact-email CONTACT_EMAIL]
                [--external-description EXTERNAL_DESCRIPTION]
                [--external-identifier EXTERNAL_IDENTIFIER]
                [--bag-size BAG_SIZE]
                [--bag-group-identifier BAG_GROUP_IDENTIFIER]
                [--bag-count BAG_COUNT]
                [--internal-sender-identifier INTERNAL_SENDER_IDENTIFIER]
                [--internal-sender-description INTERNAL_SENDER_DESCRIPTION]
                [--bagit-profile-identifier BAGIT_PROFILE_IDENTIFIER]
                directory [directory ...]

bagit-python version 1.6.0b3.dev7+ng098c02d

BagIt is a directory, filename convention for bundling an arbitrary set of
files with a manifest, checksums, and additional metadata. More about BagIt
can be found at:

    http://purl.org/net/bagit

bagit.py is a pure python drop in library and command line tool for creating,
and working with BagIt directories.

Command-Line Usage:

Basic usage is to give bagit.py a directory to bag up:

    $ bagit.py my_directory

This does a bag-in-place operation where the current contents will be moved
into the appropriate BagIt structure and the metadata files will be created.

You can bag multiple directories if you wish:

    $ bagit.py directory1 directory2

Optionally you can provide metadata which will be stored in bag-info.txt:

    $ bagit.py --source-organization "Library of Congress" directory

You can also select which manifest algorithms will be used:

    $ bagit.py --sha1 --md5 --sha256 --sha512 directory

Using BagIt from your Python code:

    import bagit
    bag = bagit.make_bag('example-directory', {'Contact-Name': 'Ed Summers'})
    print(bag.entries)

For more information or to contribute to bagit-python's development, please
visit https://github.com/LibraryOfCongress/bagit-python

positional arguments:
  directory             Directory which will be converted into a bag in place
                        by moving any existing files into the BagIt structure
                        and creating the manifests and other metadata.

optional arguments:
  -h, --help            show this help message and exit
  --processes PROCESSES
                        Use multiple processes to calculate checksums faster
                        (default: 1)
  --log LOG             The name of the log file (default: stdout)
  --quiet               Suppress all progress information other than errors
  --validate            Validate existing bags in the provided directories
                        instead of creating new ones
  --fast                Modify --validate behaviour to only test whether the
                        bag directory has the number of files and total size
                        specified in Payload-Oxum without performing checksum
                        validation to detect corruption.

Checksum Algorithms:
  Select the manifest algorithms used when creating bags (default=sha256, sha512)

  --sha1                Generate SHA-1 manifest when creating a bag
  --sha224              Generate SHA-224 manifest when creating a bag
  --sha384              Generate SHA-384 manifest when creating a bag
  --sha256              Generate SHA-256 manifest when creating a bag
  --sha512              Generate SHA-512 manifest when creating a bag
  --md5                 Generate MD-5 manifest when creating a bag

Optional Bag Metadata:
  --source-organization SOURCE_ORGANIZATION
  --organization-address ORGANIZATION_ADDRESS
  --contact-name CONTACT_NAME
  --contact-phone CONTACT_PHONE
  --contact-email CONTACT_EMAIL
  --external-description EXTERNAL_DESCRIPTION
  --external-identifier EXTERNAL_IDENTIFIER
  --bag-size BAG_SIZE
  --bag-group-identifier BAG_GROUP_IDENTIFIER
  --bag-count BAG_COUNT
  --internal-sender-identifier INTERNAL_SENDER_IDENTIFIER
  --internal-sender-description INTERNAL_SENDER_DESCRIPTION
  --bagit-profile-identifier BAGIT_PROFILE_IDENTIFIER
johnscancella commented 7 years ago

looks good except for the line

Basic usage is to give bag a directory to bag up:

I think you meant to say

Basic usage is to give bagit.py a directory to bag up: