29
29
import termios
30
30
import threading
31
31
from decimal import Decimal
32
+ from importlib .metadata import version as get_version
32
33
33
34
import attrs
34
35
from path import Path
@@ -237,15 +238,24 @@ async def keyboard(
237
238
238
239
def parse_args ():
239
240
"""Parse command-line arguments."""
241
+ version = get_version ("stepup" )
240
242
parser = argparse .ArgumentParser (prog = "stepup" , description = "The StepUp build tool" )
241
243
parser .add_argument (
242
244
"plan_py" , type = Path , default = Path ("plan.py" ), help = "Top-level build script" , nargs = "?"
243
245
)
244
246
parser .add_argument (
245
- "--root" ,
246
- type = Path ,
247
- default = Path (os .getenv ("STEPUP_ROOT" , os .getcwd ())),
248
- help = "Directory containing top-level plan.py [default=%(default)s]" ,
247
+ "--explain-rerun" ,
248
+ "-e" ,
249
+ default = False ,
250
+ action = "store_true" ,
251
+ help = "Explain for every step with recording info why it cannot be skipped." ,
252
+ )
253
+ parser .add_argument (
254
+ "--log-level" ,
255
+ "-l" ,
256
+ default = "WARNING" ,
257
+ choices = ["DEBUG" , "INFO" , "WARNING" , "ERROR" , "CRITICAL" ],
258
+ help = "Set the logging level. [default=%(default)s]" ,
249
259
)
250
260
parser .add_argument (
251
261
"--num-workers" ,
@@ -256,20 +266,27 @@ def parse_args():
256
266
"When given as a real number with digits after the comma, "
257
267
"it is multiplied with the number of available cores. [default=%(default)s]" ,
258
268
)
269
+ parser .add_argument (
270
+ "--perf" ,
271
+ default = None ,
272
+ nargs = "?" ,
273
+ const = 500 ,
274
+ help = "Run the director under perf record, by default at a frequency of 500 Hz." ,
275
+ )
276
+ parser .add_argument (
277
+ "--root" ,
278
+ type = Path ,
279
+ default = Path (os .getenv ("STEPUP_ROOT" , os .getcwd ())),
280
+ help = "Directory containing top-level plan.py [default=%(default)s]" ,
281
+ )
259
282
parser .add_argument (
260
283
"--show-perf" ,
261
284
"-s" ,
262
285
default = 0 ,
263
286
action = "count" ,
264
287
help = "Show the performance info on each line. Repeat for more detailed info." ,
265
288
)
266
- parser .add_argument (
267
- "--explain-rerun" ,
268
- "-e" ,
269
- default = False ,
270
- action = "store_true" ,
271
- help = "Explain for every step with recording info why it cannot be skipped." ,
272
- )
289
+ parser .add_argument ("--version" , "-V" , action = "version" , version = "%(prog)s " + version )
273
290
parser .add_argument (
274
291
"--watch" ,
275
292
"-w" ,
@@ -287,20 +304,7 @@ def parse_args():
287
304
help = "Start the runner after observing the first file change in watch mode. "
288
305
"This implies --watch. (Only supported on Linux.)" ,
289
306
)
290
- parser .add_argument (
291
- "--perf" ,
292
- default = None ,
293
- nargs = "?" ,
294
- const = 500 ,
295
- help = "Run the director under perf record, by default at a frequency of 500 Hz." ,
296
- )
297
- parser .add_argument (
298
- "--log-level" ,
299
- "-l" ,
300
- default = "WARNING" ,
301
- choices = ["DEBUG" , "INFO" , "WARNING" , "ERROR" , "CRITICAL" ],
302
- help = "Set the logging level. [default=%(default)s]" ,
303
- )
307
+
304
308
args = parser .parse_args ()
305
309
if args .watch_first :
306
310
args .watch = True
0 commit comments