From ddc31231f42d61f1c2116f95b46583f1c0dd41eb Mon Sep 17 00:00:00 2001 From: Flancian <0@flancia.org> Date: Sun, 24 Sep 2023 18:53:47 +0200 Subject: [PATCH] autopushed --- bin/primes.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/primes.py b/bin/primes.py index 166891432..05c591ccc 100755 --- a/bin/primes.py +++ b/bin/primes.py @@ -9,6 +9,17 @@ import math # I'm not proud (I am a little bit?). PROOF = [] # :) +class RichGroup(click.Group): + def format_help(self, ctx, formatter): + sio = io.StringIO() + console = rich.Console(file=sio, force_terminal=True) + console.print("Hello, [bold magenta]World[/bold magenta]!", ":vampire:") + formatter.write(sio.getvalue()) + +@click.group(cls=RichGroup) +def cli(): + pass + def factor(n): for i in range(2, n+1): click.echo(f"Is {i} a factor of {n}, I wonder?") @@ -40,8 +51,9 @@ def is_prime(n): return is_prime[n] @click.command() +@click.group(cls=RichGroup) @click.argument('n', type=click.INT) -def prime(n, n0, n1): +def prime(n): """Simple program that factors a number using a [[Sieve of Eratosthenes]].""" if is_prime(n): click.echo(f"[[{n}]] is prime.")