Skip to content

Commit

Permalink
feat: Improve Rosemary
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Jun 12, 2024
1 parent b7bd36f commit 2b69839
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rosemary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from rosemary.commands.linter import linter
from rosemary.commands.selenium import selenium
from rosemary.commands.update import update
from rosemary.commands.info import info
from rosemary.commands.info import info, info2
from rosemary.commands.make_module import make_module
from rosemary.commands.env import env
from rosemary.commands.test import test
Expand All @@ -38,6 +38,7 @@ def cli():

cli.add_command(update)
cli.add_command(info)
cli.add_command(info2)
cli.add_command(make_module)
cli.add_command(env)
cli.add_command(test)
Expand Down
30 changes: 30 additions & 0 deletions rosemary/commands/info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click
import base64
import pkg_resources


Expand Down Expand Up @@ -29,3 +30,32 @@ def info():
click.echo(f"Author: {author}")
click.echo(f"Author-email: {author_email}")
click.echo(f"Description: {description}")


@click.command('love:me', hidden=True)
@click.option('--again', is_flag=True)
def info2(again):
if not again:
click.echo(click.style("Love me --again?", fg='magenta'))
return

lyrics = "ICAgIA0KICAgIEtub3cgSSd2ZSBkb25lIHdyb25nLA0KICAgIExlZnQgeW91ciBoZWFydCB0b3JuDQogICAgSXMgdGhhdCB3aGF0IGRldmlscyBkbz8NCiAgICBUb29rIHlvdSBzbyBsb3csDQogICAgV2hlcmUgb25seSBmb29scyBnbw0KICAgIEkgc2hvb2sgdGhlIGFuZ2VsIGluIHlvdSENCiAgICANCiAgICBOb3cgSSdtIHJpc2luZyBmcm9tIHRoZSBncm91bmQNCiAgICBSaXNpbmcgdXAgdG8geW91IQ0KICAgIEZpbGxlZCB3aXRoIGFsbCB0aGUgc3RyZW5ndGggSSd2ZSBmb3VuZCwNCiAgICBUaGVyZSdzIG5vdGhpbmcgSSBjYW4ndCBkbyENCiAgICANCiAgICB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25vdyBub3cuIFJvc2VtYXJ5LCBjYW4geW91IGxvdmUgbWUgYWdhaW4/DQoNCiAgICBDb25ncmF0dWxhdGlvbnMsIHlvdSBmb3VuZCB0aGUgZWFzdGVyIGVnZyE=" # noqa

decoded = decode_lyrics(lyrics)
colored_lyrics = colorize_lyrics(decoded)
click.echo(colored_lyrics)


def colorize_lyrics(lyrics):
colored_lyrics = ""
colors = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']

for i, line in enumerate(lyrics.splitlines()):
colored_lyrics += click.style(line, fg=colors[i % len(colors)]) + '\n'

return colored_lyrics


def decode_lyrics(encoded_lyrics):
decoded_lyrics = base64.b64decode(encoded_lyrics.encode('utf-8')).decode('utf-8')
return decoded_lyrics

0 comments on commit 2b69839

Please sign in to comment.