-
-
Notifications
You must be signed in to change notification settings - Fork 606
/
list_roots.py
31 lines (21 loc) · 862 Bytes
/
list_roots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from pants.engine.console import Console
from pants.engine.goal import Goal, GoalSubsystem, LineOriented
from pants.engine.rules import goal_rule, register_rules
from pants.source.source_root import AllSourceRoots
class RootsSubsystem(LineOriented, GoalSubsystem):
"""List the repo's registered source roots."""
name = "roots"
class Roots(Goal):
subsystem_cls = RootsSubsystem
@goal_rule
async def list_roots(
console: Console, roots_subsystem: RootsSubsystem, asr: AllSourceRoots
) -> Roots:
with roots_subsystem.line_oriented(console) as print_stdout:
for src_root in asr:
print_stdout(src_root.path or ".")
return Roots(exit_code=0)
def rules():
return register_rules()