Skip to content

Commit

Permalink
first organization for code, libs and commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Te-k committed Sep 25, 2017
1 parent f27dfbc commit 2636c8c
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
Empty file added harpoon/__init__.py
Empty file.
Empty file added harpoon/commands/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions harpoon/commands/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Command(object):
def add_arguments(self, parser):
pass
13 changes: 13 additions & 0 deletions harpoon/commands/bitly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /usr/bin/env python
from harpoon.commands.base import Command
from harpoon.lib.bitly import Bitly

class CommandBitly(Command):
name = "bitly"

def run(self):
print('Bitly')

def add_arguments(self, parser):
parser.add_argument('--hash', '-H', help='HASH of a link')
parser.add_argument('--file', '-f', help='File containing list of hashes')
32 changes: 32 additions & 0 deletions harpoon/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import sys
import argparse
from harpoon.commands.base import Command

def init_plugins():
plugin_dir = os.path.dirname(os.path.realpath(__file__)) + '/commands'
plugin_files = [x[:-3] for x in os.listdir(plugin_dir) if x.endswith(".py")]
sys.path.insert(0, plugin_dir)
for plugin in plugin_files:
mod = __import__(plugin)

PLUGINS = {}
for plugin in Command.__subclasses__():
PLUGINS[plugin.name] = plugin()
return PLUGINS


def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(help='Commands')

plugins = init_plugins()
for p in plugins:
sp = subparsers.add_parser(plugins[p].name, help='...')
plugins[p].add_arguments(sp)
sp.set_defaults(command=p)

args = parser.parse_args()
print(args)

print(plugins)
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from setuptools import setup

setup(
name='harpoon',
version='0.1',
description='Another OSINT CLI tool',
url='https://github.com/Te-k/harpoon',
author='Tek',
author_email='[email protected]',
keywords='osint',
install_requires=['requests', 'click'],
license='GPLv3',
packages=['harpoon', 'harpoon.commands'],
entry_points= {
'console_scripts': [ 'harpoon=harpoon.main:main' ]
}
)

0 comments on commit 2636c8c

Please sign in to comment.