# Path: googkit/lib/argument.py
# class ArgumentParser(object):
#     """Parser class that parses command line arguments.
#     """
# 
#     """RegExp to check whether the string is a parameter.
#     The parameter should have a prefixed-hyphen.
#     """
#     OPTION_PATTERN = re.compile('(--?\w+)(?:=(.+))?')
# 
#     @classmethod
#     def parse(self, argv):
#         """Split an argv into sub command parts and option parts.
#         The return value is an instance of Argument.
#         """
#         commands = []
#         options = {}
# 
#         for arg in argv[1:]:
#             if ArgumentParser._is_option(arg):
#                 key, value = ArgumentParser._parse_option(arg)
#                 options[key] = value
#             else:
#                 commands.append(arg)
# 
#         return Argument(commands, options)
# 
#     @classmethod
#     def _is_option(cls, arg):
#         return ArgumentParser.OPTION_PATTERN.match(arg)
# 
#     @classmethod
#     def _parse_option(cls, option):
#         m = ArgumentParser.OPTION_PATTERN.match(option)
#         if m is None:
#             return (option, True)
# 
#         if m.lastindex == 1:
#             return (m.group(1), True)
# 
#         return (m.group(1), m.group(2))


import unittest
from googkit.lib.argument import ArgumentParser


class TestArgumentParser(unittest.TestCase):
    def assertListEqual(self, actual, expected, msg=None):
        if hasattr(self, 'assertItemsEqual'):
            self.assertItemsEqual(actual, expected, msg)
        else:
            self.assertCountEqual(actual, expected, msg)

    def test_parse_with_no_args(self):
        arg = ArgumentParser.parse([])
        self.assertListEqual(arg.commands, [])
        self.assertEqual(len(arg.options.keys()), 0)

    def test_parse_with_commands(self):
        arg = ArgumentParser.parse(['googkit.py', 'cmd1', 'cmd2', 'cmd3'])
        self.assertListEqual(arg.commands, ['cmd1', 'cmd2', 'cmd3'])
        self.assertEqual(len(arg.options.keys()), 0)

    def test_parse_with_key_value_option(self):

# Path: googkit/lib/argument.py
# class ArgumentParser(object):
#     """Parser class that parses command line arguments.
#     """
# 
#     """RegExp to check whether the string is a parameter.
#     The parameter should have a prefixed-hyphen.
#     """
#     OPTION_PATTERN = re.compile('(--?\w+)(?:=(.+))?')
# 
#     @classmethod
#     def parse(self, argv):
#         """Split an argv into sub command parts and option parts.
#         The return value is an instance of Argument.
#         """
#         commands = []
#         options = {}
# 
#         for arg in argv[1:]:
#             if ArgumentParser._is_option(arg):
#                 key, value = ArgumentParser._parse_option(arg)
#                 options[key] = value
#             else:
#                 commands.append(arg)
# 
#         return Argument(commands, options)
# 
#     @classmethod
#     def _is_option(cls, arg):
#         return ArgumentParser.OPTION_PATTERN.match(arg)
# 
#     @classmethod
#     def _parse_option(cls, option):
#         m = ArgumentParser.OPTION_PATTERN.match(option)
#         if m is None:
#             return (option, True)
# 
#         if m.lastindex == 1:
#             return (m.group(1), True)
# 
#         return (m.group(1), m.group(2))


# Path: test/lib/test_argument.py
import unittest
from googkit.lib.argument import ArgumentParser



class TestArgumentParser(unittest.TestCase):
    def assertListEqual(self, actual, expected, msg=None):
        if hasattr(self, 'assertItemsEqual'):
            self.assertItemsEqual(actual, expected, msg)
        else:
            self.assertCountEqual(actual, expected, msg)

    def test_parse_with_no_args(self):
        arg = ArgumentParser.parse([])
        self.assertListEqual(arg.commands, [])
        self.assertEqual(len(arg.options.keys()), 0)

    def test_parse_with_commands(self):
        arg = ArgumentParser.parse(['googkit.py', 'cmd1', 'cmd2', 'cmd3'])
        self.assertListEqual(arg.commands, ['cmd1', 'cmd2', 'cmd3'])
        self.assertEqual(len(arg.options.keys()), 0)

    def test_parse_with_key_value_option(self):

        arg = ArgumentParser.parse(['googkit.py', '--opt1=value'])