Parse command line arguments after setting basic options.
    If successfully parsed, set logging verbosity.
    This function accepts variable keyword arguments.
    Their values are passed to :meth:`ArgumentParser.add_argument`.
    If special keyword `flags` is given, it'll be converted as flag option.

    Examples - multiple files including zero ::

        cliargs = parse_arguments(files=dict(nargs='*'))
        if cliargs.files:
            for fp in cliargs.files:
                print(fp.name)

    Examples - only one file (but property is list of files) ::

        cliargs = parse_arguments(files=dict(nargs=1))
        fp = cliargs.files[0]
        print(fp.name)

    Examples - mode switch of defined values ::

        cliargs = parse_arguments(mode=dict(
                    flags=('-m', '--mode'), required=True,
                    choices=("A", "B", "C")))
        print(cliargs.mode)

    :param kwargs: keywords arguments to pass :meth:`add_argument` method.
    :rtype: NameSpace object

def parse_arguments(**kwargs):
    """ Parse command line arguments after setting basic options.
    If successfully parsed, set logging verbosity.
    This function accepts variable keyword arguments.
    Their values are passed to :meth:`ArgumentParser.add_argument`.
    If special keyword `flags` is given, it'll be converted as flag option.

    Examples - multiple files including zero ::

        cliargs = parse_arguments(files=dict(nargs='*'))
        if cliargs.files:
            for fp in cliargs.files:
                print(fp.name)

    Examples - only one file (but property is list of files) ::

        cliargs = parse_arguments(files=dict(nargs=1))
        fp = cliargs.files[0]
        print(fp.name)

    Examples - mode switch of defined values ::

        cliargs = parse_arguments(mode=dict(
                    flags=('-m', '--mode'), required=True,
                    choices=("A", "B", "C")))
        print(cliargs.mode)

    :param kwargs: keywords arguments to pass :meth:`add_argument` method.
    :rtype: NameSpace object
    """
    parser = argparse.ArgumentParser(parents=[base_parser(), ])

    for name in kwargs:
        opts = kwargs[name]
        if 'flags' in opts:
            opts['dest'] = name
            name_or_flags = opts['flags']
            del opts['flags']
        else:
            name_or_flags = name
        if name == 'files':
            opts['type'] = argparse.FileType('r')
            opts['metavar'] = "FILE"
        parser.add_argument(name_or_flags, **opts)

    try:
        args = parser.parse_args()
    except IOError:
        e = sys.exc_info()[1]
        parser.error("File not found: %s" % (e, ))

    if args.quiet:
        logging.basicConfig(level=logging.CRITICAL)
    elif args.verbose >= 3:
        logging.basicConfig(level=logging.DEBUG)
        if args.processes:
            import multiprocessing.util
            multiprocessing.util.log_to_stderr(logging.DEBUG)
    elif args.verbose >= 2:
        logging.basicConfig(level=logging.INFO)
    elif args.verbose >= 1:
        logging.basicConfig(level=logging.WARN)
    else:
        logging.basicConfig(level=logging.ERROR)

    return args