diff --git a/dotfiles/lib/python/imalison.py b/dotfiles/lib/python/imalison.py index 3ea633e8..28127eb2 100644 --- a/dotfiles/lib/python/imalison.py +++ b/dotfiles/lib/python/imalison.py @@ -29,14 +29,14 @@ def command_exists(command, run=run): def build_task_factory(ns): - def task(function): - ns.add_task(ctask(function)) + def task(function, *args, **kwargs): + ns.add_task(ctask(function, *args, **kwargs)) return function return task -def namespace_and_factory(): - ns = Collection() +def namespace_and_factory(*args, **kwargs): + ns = Collection(*args, **kwargs) return ns, build_task_factory(ns) @@ -48,17 +48,17 @@ def extension_checker(extension): def tasks_from_directory(directory_path, file_predicate=extension_checker("sh")): - ns, make_task = namespace_and_factory() - + ns, make_task = namespace_and_factory(os.path.basename(directory_path)) def task_from_file(filepath): - @make_task() def run_script(ctx): ctx.run(filepath) - return run_script + return make_task(run_script, name=os.path.basename(filepath).split(os.path.extsep)[0]) - filepaths = filter(os.path.isfile, - [os.path.join(directory_path, filename) - for filename in os.listdir(directory_path)]) + filepaths = filter( + os.path.isfile, + [os.path.join(directory_path, filename) + for filename in os.listdir(directory_path)], + ) - map(task_from_file, filepaths) + list(map(task_from_file, filepaths)) return ns diff --git a/tasks/imalison.py b/tasks/imalison.py new file mode 120000 index 00000000..1fd67b65 --- /dev/null +++ b/tasks/imalison.py @@ -0,0 +1 @@ +../dotfiles/lib/python/imalison.py \ No newline at end of file