Add setup_fingerprint_check/src/setup_fingerprint_check/cli.py
This commit is contained in:
parent
8b0abb99cc
commit
0805c7a27f
1 changed files with 41 additions and 0 deletions
41
setup_fingerprint_check/src/setup_fingerprint_check/cli.py
Normal file
41
setup_fingerprint_check/src/setup_fingerprint_check/cli.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import argparse
|
||||
import sys
|
||||
from setup_fingerprint_check.core import check_setup_fingerprint
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""CLI entrypoint for setup fingerprint verification."""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Verify that the current setup fingerprint matches the expected one."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--expected",
|
||||
required=True,
|
||||
help="Expected fingerprint of the test setup.",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
expected_fingerprint: str = args.expected.strip()
|
||||
|
||||
# Basic validation for input integrity
|
||||
if not expected_fingerprint:
|
||||
print("Error: Expected fingerprint cannot be empty.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
matches = check_setup_fingerprint(expected_fingerprint)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
print(f"Error: Fingerprint verification failed ({exc}).", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if matches:
|
||||
print("valid")
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("mismatch")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in a new issue