-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update * try something * update * Generate new screengrabs with rich-codex * updates * experiment * update * Generate new screengrabs with rich-codex * update * updates * Generate new screengrabs with rich-codex * almost done with docs * Generate new screengrabs with rich-codex * update * delete unused file --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
59c390b
commit 7273b45
Showing
48 changed files
with
2,535 additions
and
1,352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import click | ||
|
||
@click.command() | ||
def hello(): | ||
"""Prints 'hello, world!' into the terminal.""" | ||
print("Hello, world!") | ||
|
||
if __name__ == "__main__": | ||
hello() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import rich_click as click | ||
|
||
@click.group("greetings") | ||
def greetings_cli(): | ||
"""CLI for greetings.""" | ||
|
||
@greetings_cli.command("english") | ||
@click.argument("name") | ||
def english(name): | ||
"""Greet in English""" | ||
print(f"Hello, {name}!") | ||
|
||
@greetings_cli.command("french") | ||
@click.argument("name") | ||
def french(name): | ||
"""Greet in French""" | ||
print(f"Bonjour, {name}!") | ||
|
||
if __name__ == "__main__": | ||
greetings_cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import click | ||
|
||
@click.command() | ||
@click.argument("name") | ||
@click.option("--times", "-t", | ||
default=1, | ||
type=click.INT, | ||
show_default=True, | ||
help="Number of times to print the greeting.") | ||
@click.option("--say-goodbye", | ||
is_flag=True, | ||
default=False, | ||
help="After saying hello, say goodbye.") | ||
def hello(name, times, say_goodbye): | ||
"""Prints 'hello, [name]!' into the terminal N times.""" | ||
for t in range(times): | ||
print(f"Hello, {name}!") | ||
if say_goodbye: | ||
print("Goodbye!") | ||
|
||
if __name__ == "__main__": | ||
hello() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import click | ||
|
||
@click.group("greetings") | ||
def greetings_cli(): | ||
"""CLI for greetings.""" | ||
|
||
@greetings_cli.command("english") | ||
@click.argument("name") | ||
def english(name): | ||
"""Greet in English""" | ||
print(f"Hello, {name}!") | ||
|
||
@greetings_cli.command("french") | ||
@click.argument("name") | ||
def french(name): | ||
"""Greet in French""" | ||
print(f"Bonjour, {name}!") | ||
|
||
if __name__ == "__main__": | ||
greetings_cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# This is a fleshed-out application built with Click. | ||
# (Except for the fact that it doesn't do anything!) | ||
# | ||
# Run the command `rich-click app:main --help` to render it with rich-click! | ||
import logging | ||
|
||
import click | ||
from rich.logging import RichHandler | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.addHandler(RichHandler()) | ||
logger.setLevel(logging.INFO) | ||
|
||
@click.group("my-app") | ||
@click.option("--environment", "-e", | ||
type=click.Choice(["production", "staging", "integration"]), | ||
default="production", | ||
show_default=True, | ||
help="Environment to run in.") | ||
@click.version_option(version="1.0.1", prog_name="my-app") | ||
def main(environment): | ||
"""CLI for my-app""" | ||
logger.debug("Running in environment=%s", environment) | ||
|
||
|
||
@main.command("deploy") | ||
@click.argument("version") | ||
@click.pass_context | ||
def deploy(ctx, version): | ||
"""Deploy my-app""" | ||
logger.info("Deploying version=%s in environment=%s", version, ctx.parent.params["environment"]) | ||
|
||
@main.group("user") | ||
def user_cli(): | ||
"""Manage users to my-app""" | ||
|
||
@user_cli.command("create") | ||
@click.option("--email", "-e", | ||
required=True, | ||
help="User's email") | ||
@click.password_option("--password", "-p", | ||
required=True, | ||
prompt=True, | ||
help="User's password") | ||
@click.option("--admin", | ||
is_flag=True, | ||
default=False, | ||
help="If flag is passed, give admin permissions") | ||
@click.pass_context | ||
def create(ctx, email, password, admin): | ||
"""Create my-app users""" | ||
if len(password) < 6: | ||
logger.error("Password must be ≥ 6 characters") | ||
ctx.exit(1) | ||
logger.info("Creating user with email=%s admin=%s", email, admin) | ||
|
||
|
||
@user_cli.command("delete") | ||
@click.argument("user_id", | ||
type=click.INT) | ||
def delete(user_id): | ||
"""Delete my-app users""" | ||
click.confirm(click.style(f"Are you sure you want to delete user={user_id!r}?", fg="red"), abort=True) | ||
logger.info("Deleting user with user_id=%i", user_id) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.