Skip to content

Commit 9adedc2

Browse files
authored
Merge pull request #17 from Swiddis/feature/client-arg
Add `--client` default arg
2 parents 8c72cf7 + e51db18 commit 9adedc2

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ are relevant for the hook's check. The default is `{defaultScope}`.
6262

6363
[NOTE]
6464
--
65-
All hooks have an optional `project-dir` arugument, which is useful for monorepos that do not have a `build.sbt` in their root.
66-
All hooks have an optional `no-clean` arugument, which won't automatically run an `sbt clean` before executing the command.
65+
All hooks have an optional `project-dir` argument, which is useful for monorepos that do not have a `build.sbt` in their root.
66+
All hooks have an optional `no-clean` argument, which won't automatically run an `sbt clean` before executing the command.
67+
All hooks have an optional `client` argument, which will persist the SBT session across invocations on newer SBT versions.
6768
--
6869

6970
[IMPORTANT]

pre_commit_hooks/runner.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Opts:
99
project_dir: str | None = None
1010
clean: bool = True
1111
varargs: dict = field(default_factory=dict)
12+
client: bool = False
1213

1314

1415
def default_argparse(
@@ -28,12 +29,19 @@ def default_argparse(
2829
default=False,
2930
help="Turn off sbt clean. Default: False",
3031
)
32+
arg_p.add_argument(
33+
"--client",
34+
action="store_true",
35+
default=False,
36+
help="Run sbt in --client mode, persisting sessions across commits. Default: False",
37+
)
3138
for fn in additional_args:
3239
fn(arg_p)
3340
varags = vars(arg_p.parse_args(argv))
3441
return Opts(
3542
project_dir=varags.pop("project_dir", None),
3643
clean=not varags.pop("no_clean", False),
44+
client=varags.pop("client", False),
3745
varargs=varags,
3846
)
3947

@@ -45,12 +53,13 @@ def run_sbt_command(
4553
opts: Opts = Opts(),
4654
):
4755
print(f"Running SBT command: {task_def} with options: {opts}")
56+
sbt_args = "--client" if opts.client else ""
4857
if opts.clean:
4958
task_def = f"; clean ; {task_def}"
5059
else:
5160
task_def = f"; {task_def}"
5261
sbt_process = subprocess.run(
53-
[f"sbt '{task_def}'"],
62+
[f"sbt {sbt_args} '{task_def}'"],
5463
stdout=subprocess.PIPE,
5564
stderr=subprocess.STDOUT,
5665
shell=True,

0 commit comments

Comments
 (0)