From 7c81a21a1f9f7d7f2a25e1c5d5996acfe89c6cbd Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Wed, 14 Aug 2024 16:58:20 +0200 Subject: [PATCH] added cli for generating a list of ints --- pyproject.toml | 1 + work_helpers/random_int.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 work_helpers/random_int.py diff --git a/pyproject.toml b/pyproject.toml index 499a070..16f9336 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ requires = [ [tool.flit.scripts] nice_path = "work_helpers.nice_path:make_nice_path" random_password = "work_helpers.password:get_random_password" +random_ints = "work_helpers.random_int:generate_random_number_list" sensospot_rename = "work_helpers.sensospot_rename:sensospot_rename" sg_list_frms = "work_helpers.sg_frm_list:cli" sg_mbp_new_version = "work_helpers.sg_mbp_build:sg_mbp_new_version" diff --git a/work_helpers/random_int.py b/work_helpers/random_int.py new file mode 100644 index 0000000..30f7024 --- /dev/null +++ b/work_helpers/random_int.py @@ -0,0 +1,15 @@ +import click +import random +import pyperclip + +@click.command() +@click.argument("length", default=100, type=int) +def generate_random_number_list(length=100): + """ generates a new line separated list of integers and copies it to the clipboard """ + numbers = list(range(1, length + 1)) + random.shuffle(numbers) + integer_list = "\n".join(str(i) for i in numbers) + pyperclip.copy(integer_list) + click.echo("Copied to clipboard:", err=True) + click.echo(integer_list) + \ No newline at end of file