summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xqface-cli.py (renamed from cli.py)47
-rw-r--r--setup.py10
2 files changed, 15 insertions, 42 deletions
diff --git a/cli.py b/qface-cli.py
index 833df20..d4a620c 100755
--- a/cli.py
+++ b/qface-cli.py
@@ -103,53 +103,30 @@ class RunScriptChangeHandler(FileSystemEventHandler):
@cli.command()
+@click.argument('script', nargs=1, type=click.Path(exists=True))
@click.argument('input', nargs=-1, type=click.Path(exists=True))
@click.argument('output', nargs=1, type=click.Path(exists=True))
-@click.option('--runner', type=click.File('r'), help="use the runner YAML file to configure the generation")
-@click.option('--reload/--no-reload', default=False, help="if enabled auto-reload the generator on input changes")
-@click.option('--generator', help="specifies the generator (either by name or path)", required=True)
-@click.option('--clean/--no-clean', help="initially cleans the output directory")
-def generate(input, output, runner, generator, reload, clean):
- """generate from the list of input files or directories the source code
- in the output folder using the given generator."""
- generator = Path(generator).expand().abspath()
+def reload(script, input, output):
+ """
+ reloads the generator script when the script files
+ or the input files changes
+ """
+ script = Path(script).expand().abspath()
output = Path(output).expand().abspath()
input = input if isinstance(input, (list, tuple)) else [input]
- """run the named generator"""
- if runner:
- config = yaml.load(runner)
- generator = config['generator']
- input = config['input']
- output = config['output']
- # look if generator points to an external generator
- if not generator.exists():
- click.echo('genertor does not exists: {0}'.format(generator))
- sys.exit(-1)
- if clean:
- output.rmtree_p()
output.makedirs_p()
- if not reload:
- _generate_once(generator, input, output)
- else:
- _generate_reload(generator, input, output)
-
-
-def _generate_once(generator, input, output):
- in_option = ' '.join(input)
- script = 'python3 {0} {1} {2}'.format(generator, in_option, output)
- sh(script, Path.getcwd())
+ _script_reload(script, input, output)
-def _generate_reload(generator, input, output):
+def _script_reload(script, input, output):
"""run the named generator and monitor the input and generator folder"""
input = [Path(entry).expand().abspath() for entry in input]
output = Path(output).expand().abspath()
- in_option = ' '.join(input)
- script = 'python3 {0} {1} {2}'.format(generator, in_option, output)
- event_handler = RunScriptChangeHandler(script)
+ cmd = 'python3 {0} {1} {2}'.format(script, ' '.join(input), output)
+ event_handler = RunScriptChangeHandler(cmd)
event_handler.run() # run always once
observer = Observer()
- path = generator.dirname().expand().abspath()
+ path = script.dirname().expand().abspath()
click.secho('watch: {0}'.format(path), fg='blue')
observer.schedule(event_handler, path, recursive=True)
for entry in input:
diff --git a/setup.py b/setup.py
index eb98ff1..a6aeeb1 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-from setuptools import setup
+from setuptools import setup, find_packages
from codecs import open
from os import path
@@ -42,7 +42,7 @@ setup(
'Programming Language :: Python :: 3.5',
],
keywords='qt code generator framework',
- packages=['qface'],
+ packages=find_packages(),
install_requires=[
'jinja2',
'path.py',
@@ -61,9 +61,5 @@ setup(
'watchdog',
'ipdb',
],
- },
- entry_points='''
- [console_scripts]
- qface=cli:cli
- '''
+ }
)