Coverage for /home/runner/work/coxbuild/coxbuild/src/coxbuild/extensions/shell/__init__.py: 0%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import platform
3from coxbuild.schema import group, run, task
5grouped = group("shell")
8def whereCommand(name: str) -> list[str]:
9 if "windows" in platform.system().lower():
10 res = run(["where.exe", name], pipe=True, fail=True)
11 if res:
12 return [f.strip() for f in res.stdout.splitlines() if f.strip()]
13 else:
14 return []
15 else:
16 res = run(["whereis", name], pipe=True, fail=True)
17 if res:
18 return [f.strip() for f in res.stdout.split(":")[1].strip().split(" ") if f.strip()]
19 else:
20 return []
23def existCommand(name: str) -> bool:
24 return len(whereCommand(name)) > 0
27@grouped
28@task
29def execute(*args, **kwargs):
30 run(*args, **kwargs)