#!python

from argparse import ArgumentParser
from mmarch.archive import *
import logging

parser = ArgumentParser(description = 'Packing utility for MMARCH project')
parser.add_argument('--page-size', '-S', default = 4096, type = int, help = 'Page size used for aligning file data')
parser.add_argument('--big-endian', '-B', action = 'store_true', dest = 'big_endian', default = True, help = 'Store archive data in big endian format (default)')
parser.add_argument('--little-endian', '-L', action = 'store_false', dest = 'big_endian', help = 'Store archive data in little endian format')
parser.add_argument('--follow-links', '-f', action = 'store_true', help = 'Follow links')
parser.add_argument('--verbose', '-v', action = 'store_true', help = 'Verbose')
parser.add_argument('archive', help = 'destination archive file')
parser.add_argument('directories', help = 'directories to pack', nargs = '+')
args = parser.parse_args()
logging.basicConfig(level = logging.DEBUG if args.verbose else logging.INFO)

archive = Archive(options = args)
for dir in args.directories:
    archive.add_dir(dir)

with open(args.archive, 'wb') as f:
    archive.write(f)
