Create base CLI and read input files

This commit is contained in:
Jake Howard 2017-03-28 09:04:02 +01:00
parent 39ec87cc64
commit 79ec42a655
3 changed files with 10 additions and 6 deletions

View File

@ -1,5 +1,9 @@
import click
from md_pdf.build.md import read_files
@click.command('build', short_help="Build document")
def cli():
pass
@click.argument('in_files', type=click.Path(dir_okay=False, resolve_path=True, writable=True), nargs=-1)
@click.option('--output', '-o', type=click.Path(file_okay=False, resolve_path=True, writable=True), default='out/')
def cli(in_files, output):
data = read_files(in_files)
print(data)

View File

@ -6,6 +6,5 @@ def get_files_content(filenames):
yield f.read()
def read_files(files_glob):
filenames = glob.glob(files_glob)
def read_files(filenames):
return '\n'.join(list(get_files_content(filenames)))

View File

@ -23,8 +23,9 @@ class MDPDFCLI(click.MultiCommand):
code = compile(f.read(), fn, 'exec')
eval(code, ns, ns)
return ns['cli']
except:
return
except Exception as e:
print("An Error Occured:s")
raise e
cli = MDPDFCLI(help='This tool\'s subcommands are loaded from a plugin folder dynamically.')