Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 7 additions & 0 deletions Doc/library/uuid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ The following options are accepted:
The name used as part of generating the uuid. Only required for
:func:`uuid3` / :func:`uuid5` functions.

.. option:: -c <NUM>
--count <NUM>

Generate NUM fresh UUIDs.


.. _uuid-example:

Expand Down Expand Up @@ -445,3 +450,5 @@ Here are some examples of typical usage of the :mod:`uuid` command line interfac
# generate a uuid using uuid5
$ python -m uuid -u uuid5 -n @url -N example.com

# generate 42 random uuids
$ python -m uuid --count 42
8 changes: 6 additions & 2 deletions Lib/uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,8 @@ def main():
parser.add_argument("-N", "--name",
help="The name used as part of generating the uuid. "
"Only required for uuid3/uuid5 functions.")
parser.add_argument("-c", "--count", metavar="NUM", type=int, default=1,
help="Generate NUM fresh UUIDs.")

args = parser.parse_args()
uuid_func = uuid_funcs[args.uuid]
Expand All @@ -963,9 +965,11 @@ def main():
"Run 'python -m uuid -h' for more information."
)
namespace = namespaces[namespace] if namespace in namespaces else UUID(namespace)
print(uuid_func(namespace, name))
for _ in range(args.count):
print(uuid_func(namespace, name))
else:
print(uuid_func())
for _ in range(args.count):
print(uuid_func())


# The following standard UUIDs are for use with uuid3() or uuid5().
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``--count`` to main of the :mod:`uuid` module.
Loading