Skip to content

Commit

Permalink
chore: populate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aekasitt committed Dec 8, 2024
1 parent 37008bc commit 2aa59ac
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 25 deletions.
16 changes: 13 additions & 3 deletions src/arise/commands/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
16 changes: 13 additions & 3 deletions src/arise/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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()
Expand Down
12 changes: 8 additions & 4 deletions src/arise/commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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"<Container '{ container.name }'> removed.")
Expand Down
2 changes: 0 additions & 2 deletions src/arise/commands/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +24,6 @@
from arise.shadows import Bellion


@command
def dashboard() -> None:
"""Dashboard for checking current state of images deployed."""
client: DockerClient
Expand Down
15 changes: 12 additions & 3 deletions src/arise/commands/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand All @@ -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()
Expand Down
16 changes: 13 additions & 3 deletions src/arise/commands/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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()
Expand Down
14 changes: 7 additions & 7 deletions src/arise/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__":
Expand Down

0 comments on commit 2aa59ac

Please sign in to comment.