Skip to content

Commit 9597654

Browse files
michaelmckinsey1Michael Richard MckinseyMichael McKinseypearce8
authored
Print --version and --help Without Bootstrapping (#595)
* print version without bootstrapping * print help message without bootstrapping * black * Fix flake --------- Co-authored-by: Michael Richard Mckinsey <[email protected]> Co-authored-by: Michael McKinsey <[email protected]> Co-authored-by: pearce8 <[email protected]>
1 parent d625a16 commit 9597654

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

lib/main.py

+32-19
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,44 @@
1414
import sys
1515
import yaml
1616

17-
import benchpark.cmd.audit
18-
import benchpark.cmd.system
19-
import benchpark.cmd.experiment
20-
import benchpark.cmd.setup
21-
import benchpark.cmd.unit_test
22-
import benchpark.paths
23-
from benchpark.accounting import (
17+
__version__ = "0.1.0"
18+
if "-V" in sys.argv or "--version" in sys.argv:
19+
print(__version__)
20+
exit()
21+
helpstr = """usage: main.py [-h] [-V] {list,tags,system,experiment,setup,unit-test,audit} ...
22+
23+
Benchpark
24+
25+
options:
26+
-h, --help show this help message and exit
27+
-V, --version show version number and exit
28+
29+
Subcommands:
30+
{list,tags,system,experiment,setup,unit-test,audit}
31+
list List available experiments, systems, and modifiers
32+
tags Tags in Benchpark experiments
33+
system Initialize a system config
34+
experiment Interact with experiments
35+
setup Set up an experiment and prepare it to build/run
36+
unit-test Run benchpark unit tests
37+
audit Look for problems in System/Experiment repos"""
38+
if "-h" in sys.argv or "--help" in sys.argv:
39+
print(helpstr)
40+
exit()
41+
42+
import benchpark.cmd.audit # noqa: E402
43+
import benchpark.cmd.system # noqa: E402
44+
import benchpark.cmd.experiment # noqa: E402
45+
import benchpark.cmd.setup # noqa: E402
46+
import benchpark.cmd.unit_test # noqa: E402
47+
import benchpark.paths # noqa: E402
48+
from benchpark.accounting import ( # noqa: E402
2449
benchpark_experiments,
2550
benchpark_modifiers,
2651
benchpark_systems,
2752
)
2853

2954

30-
__version__ = "0.1.0"
31-
32-
3355
def main():
3456
if sys.version_info[:2] < (3, 8):
3557
raise Exception("Benchpark requires at least python 3.8+.")
@@ -53,10 +75,6 @@ def main():
5375
parser.print_help()
5476
return 1
5577

56-
if args.version:
57-
print(get_version())
58-
return 0
59-
6078
if args.subcommand in actions:
6179
action = actions[args.subcommand]
6280
if supports_unknown_args(action):
@@ -87,11 +105,6 @@ def supports_unknown_args(command):
87105
return argcount == 2 and varnames[1] == "unknown_args"
88106

89107

90-
def get_version():
91-
benchpark_version = __version__
92-
return benchpark_version
93-
94-
95108
def benchpark_list(subparsers, actions_dict):
96109
list_parser = subparsers.add_parser(
97110
"list", help="List available experiments, systems, and modifiers"

0 commit comments

Comments
 (0)