@@ -0,0 +1,2099 @@
+import os%0A%0Aimport click%0A%0A%0A@click.command()%0A@click.option(%0A    '--matcher',%0A    type=click.Choice(%5B'url', 'body', 'header'%5D),%0A    required=True,%0A    help='Set the matcher type.',%0A)%0A@click.option(%0A    '--value',%0A    type=str,%0A    required=True,%0A    help='Set the matcher value.',%0A)%0A@click.option(%0A    '--category',%0A    type=click.Choice(%5B'frontend', 'backend', 'wordpress', 'infraestructure'%5D),%0A    required=True,%0A    help='Set plugin category.',%0A)%0A@click.argument('name')%0Adef main(name, category, matcher, value):%0A    directory = os.path.dirname(__file__)%0A    if matcher == 'header':%0A        value = tuple(value.split(','))%0A%0A    create_plugin_file(directory, name, category, matcher, value)%0A    create_test_file(directory, name, matcher)%0A%0A%0Adef create_plugin_file(directory, name, category, matcher, value):%0A    plugin_template = '''%0Afrom detectem.plugin import Plugin%0A%0A%0Aclass %7Btitle%7DPlugin(Plugin):%0A    name = '%7Bname%7D'%0A    matchers = %5B%0A        %7B%7B'%7Bmatcher%7D': '%7Bvalue%7D'%7D%7D,%0A    %5D%0A'''.format(name=name, title=name.title(), matcher=matcher, value=value).lstrip()%0A%0A    plugin_filename = name + '.py'%0A    plugin_filepath = os.path.abspath(%0A        os.path.join(directory, '..', 'detectem', 'plugins', category, plugin_filename)%0A    )%0A%0A    if os.path.exists(plugin_filepath):%0A        raise FileExistsError('Plugin file already exists.')%0A%0A    with open(plugin_filepath, mode='w') as f:%0A        f.write(plugin_template)%0A        print('Created plugin file at %7B%7D'.format(plugin_filepath))%0A%0A%0Adef create_test_file(directory, name, matcher):%0A    test_template = '''%0A- plugin: %7Bname%7D%0A  matches:%0A    - %7Bmatcher%7D:%0A      version:%0A'''.format(name=name, matcher=matcher).lstrip()%0A%0A    test_filename = name + '.yml'%0A    test_filepath = os.path.abspath(%0A        os.path.join(directory, '..', 'tests', 'plugins', 'fixtures', test_filename)%0A    )%0A%0A    if os.path.exists(test_filepath):%0A        raise FileExistsError('Test file already exists.')%0A%0A    with open(test_filepath, mode='w') as f:%0A        f.write(test_template)%0A        print('Created test file at %7B%7D'.format(test_filepath))%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A

Add script to create plugins faster