File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1919from shutil import rmtree , which
2020from typing import Union
2121from collections .abc import Generator
22+ import time
2223
2324PathLike = Union [Path , str , bytes ]
2425
@@ -144,13 +145,24 @@ def run(args: str | list[str], cd: PathLike | None = None) -> None:
144145 """
145146 cmd = " " .join (args )
146147 print (">> Running command:" , cmd )
148+ start_time = time .perf_counter ()
147149 if cd is not None :
148150 with cd_context (_resolve (cd , strict = True )):
149151 result = subprocess .run (args )
150152 else :
151153 result = subprocess .run (args )
152-
153- print (">> Command finished:" , cmd , "\n " )
154+
155+ elapsed_time = time .perf_counter () - start_time
156+ h , rem = divmod (elapsed_time , 3600 )
157+ m , s = divmod (rem , 60 )
158+
159+ time_str = " " .join (part for part in [
160+ f"{ int (h )} h" if h >= 1 else "" ,
161+ f"{ int (m )} m" if m >= 1 or h >= 1 else "" ,
162+ f"{ int (s )} s"
163+ ] if part )
164+
165+ print (f">> Command finished ({ time_str } ): { cmd } \n " )
154166
155167 # TODO: Should we exit here? Or continue to let other commands run also?
156168 if result .returncode != 0 :
You can’t perform that action at this time.
0 commit comments