#! /usr/bin/env python2

import sys
import argparse

def see(expr):
  value = eval(expr)
  sys.stderr.write('{expr}: {value!r}\n'.format(**locals()))

parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', dest='verbose', action='count',  help='Toggle verbose debugging')
parser.add_argument('--cfg', dest='cfg', help='Specify configuration filename', required=True)

group = parser.add_mutually_exclusive_group()
group.add_argument('--opt1', dest='opt1', action='store_true',  help='Option 1')
group.add_argument('--opt2', dest='opt2', action='store_true',  help='Option 2')

parser.add_argument('pattern', help='Regular expression pattern')
parser.add_argument('files', metavar='files', nargs='*', help='Files to process')

args = parser.parse_args()

# args.verbose is None if not specified - to test toggling, try `(args.verbose if args.verbose else 0) % 2` or `(args.verbose or 0) % 2`
see('args.verbose')

see('args.cfg')
see('args.pattern')
see('args.files')
see('args.opt1')
see('args.opt2')

print 'Done'
