From 7e017a3de0012464fd508f4b2e192850a5b029ec Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 20 Sep 2019 19:30:12 -0400 Subject: [PATCH] --levels --- bake/cli.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/bake/cli.py b/bake/cli.py index 999b768..8c27aab 100644 --- a/bake/cli.py +++ b/bake/cli.py @@ -100,12 +100,18 @@ def echo_json(obj): ) @click.option( "--list", - "-l", "_list", default=False, is_flag=True, help="Lists available tasks (and their dependencies).", ) +@click.option( + "--levels", + "-l", + default=1, + nargs=1, + help="Lists available tasks (and their dependencies).", +) @click.option( "--help", "-h", default=False, is_flag=True, help="Show this message and exit." ) @@ -179,6 +185,7 @@ def entrypoint( bakefile, arguments, _list, + levels, _continue, environ_json, debug, @@ -283,7 +290,12 @@ def entrypoint( if _list: __list_json = {"tasks": {}} + task_list = [] for _task in bakefile.tasks: + if len(_task.split("/")) <= levels: + task_list.append(_task) + + for _task in task_list: depends_on = bakefile[_task].depends_on( include_filters=False, recursive=True ) @@ -308,6 +320,17 @@ def entrypoint( err=False, ) + if not silent: + tasks_unechoed = len(bakefile.tasks) - len(task_list) + bake_command = str(click.style(f"bake -l {levels + 1}", fg="red")) + if tasks_unechoed: + # click.echo(err=True) + click.echo( + f"Note: {tasks_unechoed} more tasks are available. " + f"Please use $ {bake_command} to see more.", + err=True, + ) + if _json: echo_json(__list_json)