From a06d1a3269fa9560d0717738b4d3bde6712adab2 Mon Sep 17 00:00:00 2001 From: jay23606 <4602056+jay23606@users.noreply.github.com> Date: Mon, 19 Oct 2026 05:52:41 -0400 Subject: [PATCH] Add UUID generator command --- fixit/cli.py | 7 +++++++ tests/test_uuid.py | 13 +++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/test_uuid.py diff --git a/fixit/cli.py b/fixit/cli.py index e96c5cd..632cf17 100644 --- a/fixit/cli.py +++ b/fixit/cli.py @@ -1,6 +1,7 @@ """Command line entry point: `fixit `.""" import argparse import sys +import uuid from fixit import __version__, convert, jsonfmt, password, textutils, wordcount @@ -28,6 +29,9 @@ def build_parser() -> argparse.ArgumentParser: pw.add_argument("--length", type=int, default=12) pw.add_argument("--symbols", action="store_true") + uid = sub.add_parser("uuid", help="generate UUIDs") + uid.add_argument("--count", type=int, default=1) + js = sub.add_parser("json", help="pretty-print JSON") js.add_argument("raw") @@ -49,6 +53,9 @@ def main(argv=None) -> int: print(CONVERSIONS[args.kind](args.value)) elif args.command == "password": print(password.generate(args.length, use_symbols=args.symbols)) + elif args.command == "uuid": + for _ in range(args.count): + print(uuid.uuid4()) elif args.command == "json": print(jsonfmt.format_json(args.raw)) elif args.command == "palindrome": diff --git a/tests/test_uuid.py b/tests/test_uuid.py new file mode 100644 index 0000000..da3f651 --- /dev/null +++ b/tests/test_uuid.py @@ -0,0 +1,13 @@ +from uuid import UUID + +import pytest + +from fixit.cli import main + + +def test_uuid_command_prints_requested_number_of_uuid4_values(capsys): + main(["uuid", "--count", "3"]) + + values = capsys.readouterr().out.splitlines() + assert len(values) == 3, f"expected 3 UUIDs, got {len(values)}" + assert all(UUID(value).version == 4 for value in values)