summaryrefslogtreecommitdiff
path: root/qface/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'qface/app.py')
-rw-r--r--qface/app.py42
1 files changed, 32 insertions, 10 deletions
diff --git a/qface/app.py b/qface/app.py
index 800744a..38a26d6 100644
--- a/qface/app.py
+++ b/qface/app.py
@@ -7,39 +7,61 @@ import logging
from path import Path
from qface.generator import FileSystem, RuleGenerator
from qface.watch import monitor
+from qface.utils import load_filters
here = Path(__file__).dirname()
logging.basicConfig()
-def run(spec, src, dst):
+def run(spec, src, dst, features, force):
spec = Path(spec)
project = Path(dst).name
system = FileSystem.parse(src)
- context = {
+ extra_filters_path = spec.dirname() / 'filters.py'
+ extra_filters = load_filters(extra_filters_path)
+
+ ctx = {
'dst': dst,
'system': system,
'project': project,
}
- generator = RuleGenerator(search_path=spec.dirname() / 'templates', destination=dst, context=context)
+ generator = RuleGenerator(
+ search_path=spec.dirname() / 'templates',
+ destination=dst,
+ context=ctx,
+ features=features,
+ force=force
+ )
+ generator.filters = extra_filters
generator.process_rules(spec, system)
@click.command()
-@click.option('--spec', type=click.Path(exists=True, file_okay=True))
-@click.option('--dst', type=click.Path(exists=False, file_okay=False))
+@click.option('--rules', type=click.Path(exists=True, file_okay=True))
+@click.option('--target', type=click.Path(exists=False, file_okay=False))
@click.option('--reload/--no-reload', default=False, help="Auto reload script on changes")
-@click.argument('src', nargs=-1, type=click.Path(exists=True))
-def main(spec, dst, reload, src):
- spec = Path(spec)
+@click.option('--scaffold/--no-scaffold', default=False, help="Add extrac scaffolding code")
+@click.option('--watch', type=click.Path(exists=False, file_okay=False))
+@click.option('--feature', multiple=True)
+@click.option('--force/--no-force', default=False, help="forces overwriting of files")
+@click.argument('source', nargs=-1, type=click.Path(exists=True))
+def main(rules, target, reload, source, watch, scaffold, feature, force):
+ rules = Path(rules)
if reload:
argv = sys.argv.copy()
argv.remove('--reload')
- monitor(args=argv, watch=src + (spec.dirname(),))
+ watch_list = list(source)
+ watch_list.append(rules.dirname())
+ if watch:
+ watch_list.append(watch)
+ monitor(args=argv, watch=watch_list)
else:
- run(spec, src, dst)
+ features = set(feature)
+ if scaffold:
+ features.add('scaffold')
+ run(rules, source, target, features=features, force=force)
if __name__ == '__main__':