diff --git a/.gitignore b/.gitignore index 72364f9..10f78c0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ __pycache__/ # Distribution / packaging .Python env/ -build/ develop-eggs/ dist/ downloads/ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e33b0bf --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup + + +setup( + name="md-pdf", + version="1.0", + install_requires=[ + "beautifulsoup4==4.5.3", + "click==6.7.0", + "jinja2==2.9.5", + "pdfkit==0.6.1", + "pypandoc==1.3.3" + ], + entry_points=""" + [console_scripts] + mdp=src.cli:cli + """ +) diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/build/__init__.py b/src/build/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/build/cli.py b/src/build/cli.py new file mode 100644 index 0000000..e69de29 diff --git a/src/cli.py b/src/cli.py new file mode 100644 index 0000000..361593e --- /dev/null +++ b/src/cli.py @@ -0,0 +1,39 @@ +import os.path +import click +import logging + + +FORMAT = "[%(levelname)s]: %(message)s" +logging.basicConfig(format=FORMAT, level=logging.DEBUG) +logging.getLogger("requests").setLevel(logging.WARNING) + + +class MDPDFCLI(click.MultiCommand): + + def list_commands(self, ctx): + return ['build'] + + def get_command(self, ctx, name): + ns = {} + if name not in self.list_commands(ctx): + return + try: + fn = os.path.join(os.path.dirname(__file__), name + '/cli.py') + with open(fn) as f: + code = compile(f.read(), fn, 'exec') + eval(code, ns, ns) + return ns['cli'] + except: + return + + +cli = MDPDFCLI(help='This tool\'s subcommands are loaded from a plugin folder dynamically.') + + +@click.command(cls=MDPDFCLI) +def cli(): + pass + + +if __name__ == '__main__': + cli()