Create base CLI and read input files
This commit is contained in:
parent
39ec87cc64
commit
79ec42a655
3 changed files with 10 additions and 6 deletions
|
@ -1,5 +1,9 @@
|
||||||
import click
|
import click
|
||||||
|
from md_pdf.build.md import read_files
|
||||||
|
|
||||||
@click.command('build', short_help="Build document")
|
@click.command('build', short_help="Build document")
|
||||||
def cli():
|
@click.argument('in_files', type=click.Path(dir_okay=False, resolve_path=True, writable=True), nargs=-1)
|
||||||
pass
|
@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)
|
||||||
|
|
|
@ -6,6 +6,5 @@ def get_files_content(filenames):
|
||||||
yield f.read()
|
yield f.read()
|
||||||
|
|
||||||
|
|
||||||
def read_files(files_glob):
|
def read_files(filenames):
|
||||||
filenames = glob.glob(files_glob)
|
|
||||||
return '\n'.join(list(get_files_content(filenames)))
|
return '\n'.join(list(get_files_content(filenames)))
|
||||||
|
|
|
@ -23,8 +23,9 @@ class MDPDFCLI(click.MultiCommand):
|
||||||
code = compile(f.read(), fn, 'exec')
|
code = compile(f.read(), fn, 'exec')
|
||||||
eval(code, ns, ns)
|
eval(code, ns, ns)
|
||||||
return ns['cli']
|
return ns['cli']
|
||||||
except:
|
except Exception as e:
|
||||||
return
|
print("An Error Occured:s")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
cli = MDPDFCLI(help='This tool\'s subcommands are loaded from a plugin folder dynamically.')
|
cli = MDPDFCLI(help='This tool\'s subcommands are loaded from a plugin folder dynamically.')
|
||||||
|
|
Reference in a new issue