# Path: invtool/lib/options.py
# def build_extractor(field_name, nas_name):
#     def extractor(nas):
#         if not getattr(nas, nas_name):
#             return {}
#         data = {field_name: getattr(nas, nas_name)}
#         return data
#     return extractor
# 
# def write_num_argument(parser, name, dest, help_text, required=False):
#     parser.add_argument(
#         '--{0}'.format(name), default=None, type=int,
#         dest=dest, help=help_text, required=required
#     )
#     return parser
# 
# Path: invtool/tests/test_data.py
# TEST_NAME = lambda: 'whap{0}{1}foo'.format(
#     random.randint(0, 255), random.randint(0, 255)
# )
# 
# TEST_PORT = "8888"
# 
# TEST_NETWORK = '10.0.{0}.{1}/27'.format(
#     random.randint(0, 255), random.randint(0, 255)
# )


from invtool.lib.options import build_extractor, write_num_argument
from invtool.tests.test_data import TEST_NAME, TEST_PORT, TEST_NETWORK


def name_argument(field_name, required=False):
    def add_name_arg(parser, required=required, **kwargs):
        parser.add_argument(
            '--{0}'.format(field_name), type=str,
            dest=field_name, help="A name.",
            required=required
        )

    def test_data():
        return field_name, TEST_NAME()  # Reuse this test data


# Path: invtool/lib/options.py
# def build_extractor(field_name, nas_name):
#     def extractor(nas):
#         if not getattr(nas, nas_name):
#             return {}
#         data = {field_name: getattr(nas, nas_name)}
#         return data
#     return extractor
# 
# def write_num_argument(parser, name, dest, help_text, required=False):
#     parser.add_argument(
#         '--{0}'.format(name), default=None, type=int,
#         dest=dest, help=help_text, required=required
#     )
#     return parser
# 
# Path: invtool/tests/test_data.py
# TEST_NAME = lambda: 'whap{0}{1}foo'.format(
#     random.randint(0, 255), random.randint(0, 255)
# )
# 
# TEST_PORT = "8888"
# 
# TEST_NETWORK = '10.0.{0}.{1}/27'.format(
#     random.randint(0, 255), random.randint(0, 255)
# )


# Path: invtool/lib/core_options.py
from invtool.lib.options import build_extractor, write_num_argument
from invtool.tests.test_data import TEST_NAME, TEST_PORT, TEST_NETWORK



def name_argument(field_name, required=False):
    def add_name_arg(parser, required=required, **kwargs):
        parser.add_argument(
            '--{0}'.format(field_name), type=str,
            dest=field_name, help="A name.",
            required=required
        )

    def test_data():
        return field_name, TEST_NAME()  # Reuse this test data


    return add_name_arg, build_extractor(field_name, field_name), test_data