Skip to content

Print --version and --help Without Bootstrapping #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 32 additions & 19 deletions lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,44 @@
import sys
import yaml

import benchpark.cmd.audit
import benchpark.cmd.system
import benchpark.cmd.experiment
import benchpark.cmd.setup
import benchpark.cmd.unit_test
import benchpark.paths
from benchpark.accounting import (
__version__ = "0.1.0"
if "-V" in sys.argv or "--version" in sys.argv:
print(__version__)
exit()
helpstr = """usage: main.py [-h] [-V] {list,tags,system,experiment,setup,unit-test,audit} ...

Benchpark

options:
-h, --help show this help message and exit
-V, --version show version number and exit

Subcommands:
{list,tags,system,experiment,setup,unit-test,audit}
list List available experiments, systems, and modifiers
tags Tags in Benchpark experiments
system Initialize a system config
experiment Interact with experiments
setup Set up an experiment and prepare it to build/run
unit-test Run benchpark unit tests
audit Look for problems in System/Experiment repos"""
if "-h" in sys.argv or "--help" in sys.argv:
print(helpstr)
exit()

import benchpark.cmd.audit # noqa: E402
import benchpark.cmd.system # noqa: E402
import benchpark.cmd.experiment # noqa: E402
import benchpark.cmd.setup # noqa: E402
import benchpark.cmd.unit_test # noqa: E402
import benchpark.paths # noqa: E402
from benchpark.accounting import ( # noqa: E402
benchpark_experiments,
benchpark_modifiers,
benchpark_systems,
)


__version__ = "0.1.0"


def main():
if sys.version_info[:2] < (3, 8):
raise Exception("Benchpark requires at least python 3.8+.")
Expand All @@ -53,10 +75,6 @@ def main():
parser.print_help()
return 1

if args.version:
print(get_version())
return 0

if args.subcommand in actions:
action = actions[args.subcommand]
if supports_unknown_args(action):
Expand Down Expand Up @@ -87,11 +105,6 @@ def supports_unknown_args(command):
return argcount == 2 and varnames[1] == "unknown_args"


def get_version():
benchpark_version = __version__
return benchpark_version


def benchpark_list(subparsers, actions_dict):
list_parser = subparsers.add_parser(
"list", help="List available experiments, systems, and modifiers"
Expand Down