diff --git a/bake/bakefile.py b/bake/bakefile.py index d88b9e1..eecab83 100644 --- a/bake/bakefile.py +++ b/bake/bakefile.py @@ -252,7 +252,9 @@ class TaskScript(BaseAction): return tf - def execute(self, *, blocking=False, debug=False, silent=False, **kwargs): + def execute( + self, *, blocking=False, debug=False, interactive=False, silent=False, **kwargs + ): init_tf = self.prepare_init() if self.bashfile._is_shebang_line(self.source_lines[0]): @@ -268,7 +270,11 @@ class TaskScript(BaseAction): args = " ".join([shlex_quote(a) for a in self.bashfile.args]) - script = f"source {shlex_quote(init_tf)}; {shlex_quote(script_tf)} {args} 2>&1 | bake:indent" + if interactive: + script = f"source {shlex_quote(init_tf)}; {shlex_quote(script_tf)} {args}" + else: + script = f"source {shlex_quote(init_tf)}; {shlex_quote(script_tf)} {args} 2>&1 | bake:indent" + cmd = f"bash -c {shlex_quote(script)}" if debug: diff --git a/bake/cli.py b/bake/cli.py index 8d62314..99b4579 100644 --- a/bake/cli.py +++ b/bake/cli.py @@ -143,6 +143,13 @@ def echo_json(obj): type=click.BOOL, help="Continue, if a task fails.", ) +@click.option( + "--interactive", + "-i", + is_flag=True, + type=click.BOOL, + help="Run in interactive mode.", +) @click.option( "--insecure", is_flag=True, @@ -188,6 +195,7 @@ def entrypoint( _json, skip_done, no_deps, + interactive, yes, help, ): @@ -344,7 +352,9 @@ def entrypoint( + click.style(":", fg="white"), err=True, ) - return_code = task.execute(yes=yes, debug=debug, silent=silent) + return_code = task.execute( + yes=yes, debug=debug, silent=silent, interactive=interactive + ) if not _continue: if (not return_code == 0) and (not isinstance(return_code, tuple)): diff --git a/setup.py b/setup.py index 9cad8f8..7e71acc 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ URL = "https://github.com/kennethreitz/bake" EMAIL = "me@kennethreitz.org" AUTHOR = "Kenneth Reitz" REQUIRES_PYTHON = ">=3.6.0" -VERSION = "0.3.1" +VERSION = "0.4.0" # What packages are required for this module to be executed? REQUIRED = ["click", "delegator.py", "pygments", "networkx"]