From 2aa59ac890c8d1f966f1346f3ef64a36052109c0 Mon Sep 17 00:00:00 2001 From: Sitt Guruvanich Date: Sun, 8 Dec 2024 17:09:12 +0700 Subject: [PATCH] chore: populate documentation --- src/arise/commands/auth.py | 16 +++++++++++++--- src/arise/commands/build.py | 16 +++++++++++++--- src/arise/commands/clean.py | 12 ++++++++---- src/arise/commands/dashboard.py | 2 -- src/arise/commands/deploy.py | 15 ++++++++++++--- src/arise/commands/pull.py | 16 +++++++++++++--- src/arise/core.py | 14 +++++++------- 7 files changed, 66 insertions(+), 25 deletions(-) diff --git a/src/arise/commands/auth.py b/src/arise/commands/auth.py index 59220dc..d286c8e 100644 --- a/src/arise/commands/auth.py +++ b/src/arise/commands/auth.py @@ -16,13 +16,12 @@ from typing import Dict, List, Optional, Tuple ### Third-party packages ### -from click import argument, command, option +from click import argument, option from docker import DockerClient, from_env from docker.errors import DockerException from rich import print as rich_print -@command @argument("rpcuser", required=False) @argument("dbuser", required=False) @argument("dbpass", required=False) @@ -31,7 +30,18 @@ def auth( bash: bool, dbpass: Optional[str], dbuser: Optional[str], rpcuser: Optional[str], zsh: bool ) -> None: - """Persist authentications in desired run-control file.""" + """ + Persist authentications in desired run-control file. + + Positional arguments: + * rpcuser (optional, str) + * dbuser (optional, str) + * dbpass (optional, str) + + Options: + * bash (bool) if present, targets the run-control file belonging to bash shell. + * zsh (bool) if present, targets the run-control file belonging to zsh shell. + """ client: DockerClient try: client = from_env() diff --git a/src/arise/commands/build.py b/src/arise/commands/build.py index 8603c77..d72a64d 100644 --- a/src/arise/commands/build.py +++ b/src/arise/commands/build.py @@ -15,7 +15,7 @@ from typing import Dict, List, Set ### Third-party packages ### -from click import command, option +from click import option from docker import DockerClient, from_env from docker.errors import BuildError, DockerException from rich import print as rich_print @@ -26,7 +26,6 @@ from arise.types import Build -@command @option("--electrs", is_flag=True, help="Build arise-electrs image", type=bool) @option("--mainnet", is_flag=True, help="Build arise-mainnet image", type=bool) @option("--mariadb", is_flag=True, help="Build arise-mariadb image", type=bool) @@ -43,7 +42,18 @@ def build( signet: bool, testnet: bool, ) -> None: - """Build peripheral images for the desired cluster.""" + """ + Build peripheral images for the desired cluster. + + Options: + * electrs (bool) if present, builds `arise-electrs` with bitcoin electrum server written in rustlang + * mainnet (bool) if present, builds `arise-mainnet` image with bitcoin network daemon configured to `mainnet` + * mariadb (bool) if present, builds `arise-mariadb` image with database service + * mempool (bool) if present, builds `arise-mempool` image with mempool backend service + * mutiny-web (bool) if present, builds `arise-mutiny-web` image with MutinyWallet web application + * signet (bool) if present, builds `arise-signet` image with bitcoin network daemon configured to `signet` + * testnet (bool) if present, builds `arise-testnet` image with bitcoin network daemon configured to `testnet` + """ client: DockerClient try: client = from_env() diff --git a/src/arise/commands/clean.py b/src/arise/commands/clean.py index 0364439..07a0243 100644 --- a/src/arise/commands/clean.py +++ b/src/arise/commands/clean.py @@ -15,7 +15,7 @@ from typing import List ### Third-party packages ### -from click import command, option +from click import option from docker import DockerClient, from_env from docker.errors import DockerException, NotFound from docker.models.containers import Container @@ -27,10 +27,14 @@ from arise.configs import NETWORK -@command @option("--inactive", help="Query inactive containers for removal.", is_flag=True, type=bool) def clean(inactive: bool) -> None: - """Remove all active "arise-*" containers, drop network.""" + """ + Remove containers with baring "arise-" prefix, drop network. + + Options: + * --inactive (bool) if present, targets both active and inactive or stopped containers. + """ client: DockerClient try: client = from_env() @@ -43,7 +47,7 @@ def clean(inactive: bool) -> None: outputs: List[str] = [] containers: List[Container] = client.containers.list(all=inactive) for container in track(containers, f"Clean {('active','all')[inactive]} containers:".ljust(42)): - if match(r"arise-*", container.name) is not None: + if match(r"^arise-*", container.name) is not None: container.stop() container.remove(v=True) # if `v` is true, remove associated volume outputs.append(f" removed.") diff --git a/src/arise/commands/dashboard.py b/src/arise/commands/dashboard.py index f25d597..110fb48 100644 --- a/src/arise/commands/dashboard.py +++ b/src/arise/commands/dashboard.py @@ -15,7 +15,6 @@ from typing import List ### Third-party packages ### -from click import command from docker import DockerClient, from_env from docker.errors import DockerException from docker.models.containers import Container @@ -25,7 +24,6 @@ from arise.shadows import Bellion -@command def dashboard() -> None: """Dashboard for checking current state of images deployed.""" client: DockerClient diff --git a/src/arise/commands/deploy.py b/src/arise/commands/deploy.py index 757fa5f..c84ce27 100644 --- a/src/arise/commands/deploy.py +++ b/src/arise/commands/deploy.py @@ -15,7 +15,7 @@ from typing import Dict, List, Tuple ### Third-party packages ### -from click import command, option +from click import option from docker import DockerClient, from_env from docker.errors import APIError, DockerException from rich import print as rich_print @@ -26,7 +26,6 @@ from arise.types import Chain, Service, ServiceName -@command @option("--mainnet", cls=Chain, is_flag=True, type=bool, variants=("signet", "testnet")) @option("--signet", cls=Chain, is_flag=True, type=bool, variants=("mainnet", "testnet")) @option("--testnet", cls=Chain, is_flag=True, type=bool, variants=("mainnet", "signet")) @@ -41,7 +40,17 @@ def deploy( with_mempool: bool, with_mutiny_web: bool, ) -> None: - """Deploy cluster.""" + """ + Deploy cluster with bitcoin network daemon and peripherals. + + Options: + * --mainnet (bool) if present, deploys a bitcoin daemon configured to 'mainnet' p2p network. + * --signet (bool) if present, deploys a bitcoin daemon configured to 'signet' p2p network. + * --testnet (bool) if present, deploys a bitcoin daemon configured to 'testnet3' p2p network. + * --with-electrs (bool) if present, deploys a peripheral electrum server as well as mariadb middleware. + * --with-mempool (bool) if present, deploys a peripheral mempool backend server. + * --with-mutiny-web (bool) if present, deploys a peripheral mutiny-web web application. + """ client: DockerClient try: client = from_env() diff --git a/src/arise/commands/pull.py b/src/arise/commands/pull.py index 292bc49..ca5ff07 100644 --- a/src/arise/commands/pull.py +++ b/src/arise/commands/pull.py @@ -14,7 +14,7 @@ from typing import Dict, List, Set ### Third-party packages ### -from click import command, option +from click import option from docker import DockerClient, from_env from docker.errors import DockerException from rich import print as rich_print @@ -23,7 +23,6 @@ from arise.configs import BUILDS -@command @option("--electrs", is_flag=True, help="Build arise-electrs image", type=bool) @option("--mainnet", is_flag=True, help="Build arise-mainnet image", type=bool) @option("--mariadb", is_flag=True, help="Build arise-mariadb image", type=bool) @@ -40,7 +39,18 @@ def pull( signet: bool, testnet: bool, ) -> None: - """Pull core and peripheral images from GitHub container registry.""" + """ + Pull core and peripheral images from GitHub container registry. + + Options: + * electrs (bool) if present, pulls `arise-electrs` with bitcoin electrum server written in rustlang from ghcr.io + * mainnet (bool) if present, pulls `arise-mainnet` image with bitcoin network daemon configured to `mainnet` from ghcr.io + * mariadb (bool) if present, pulls `arise-mariadb` image with database service from ghcr.io + * mempool (bool) if present, pulls `arise-mempool` image with mempool backend service from ghcr.io + * mutiny-web (bool) if present, pulls `arise-mutiny-web` image with MutinyWallet web application from ghcr.io + * signet (bool) if present, pulls `arise-signet` image with bitcoin network daemon configured to `signet` from ghcr.io + * testnet (bool) if present, pulls `arise-testnet` image with bitcoin network daemon configured to `testnet` from ghcr.io + """ client: DockerClient try: client = from_env() diff --git a/src/arise/core.py b/src/arise/core.py index aae1705..4c1e8ce 100644 --- a/src/arise/core.py +++ b/src/arise/core.py @@ -11,7 +11,7 @@ # ************************************************************* ### Third-party packages ### -from click import group +from click import command, group ### Local modules ### from arise.commands import auth, build, clean, dashboard, deploy, pull @@ -22,12 +22,12 @@ def cli() -> None: """arise""" -cli.add_command(auth, "auth") -cli.add_command(build, "build") -cli.add_command(clean, "clean") -cli.add_command(dashboard, "dashboard") -cli.add_command(deploy, "deploy") -cli.add_command(pull, "pull") +cli.add_command(command(auth), "auth") +cli.add_command(command(build), "build") +cli.add_command(command(clean), "clean") +cli.add_command(command(dashboard), "dashboard") +cli.add_command(command(deploy), "deploy") +cli.add_command(command(pull), "pull") if __name__ == "__main__":