Skip to main content

moat-lib-run

% start main % start synopsis

Main command entry point infrastructure for MoaT applications.

% end synopsis

This module provides the infrastructure for building command-line interfaces for MoaT applications. It includes:

  • Command-line argument parsing with Click integration
  • Subcommand loading from internal modules and extensions
  • Configuration file handling
  • Logging setup
  • Main entry point wrappers for testing

Usage

Basic command setup

from moat.lib.run import main_, wrap_main

@main_.command()
async def my_command(ctx):
    """A simple command"""
    print("Hello from my command!")

Loading subcommands

Use load_subgroup to create command groups that automatically load subcommands:

from moat.lib.run import load_subgroup
import asyncclick as click

@load_subgroup(prefix="myapp.commands")
@click.pass_context
async def cli(ctx):
    """Main command group"""
    pass

Processing command-line arguments

The attr_args decorator and process_args function provide flexible argument handling:

from moat.lib.run import attr_args, process_args

@main_.command()
@attr_args(with_path=True)
async def configure(**kw):
    """Configure the application"""
    config = process_args({}, **kw)
    # config now contains parsed arguments

Key Functions

  • main_: The default main command handler
  • wrap_main: Wrapper for the main command, useful for testing
  • load_subgroup: Decorator to create command groups with automatic subcommand loading
  • attr_args: Decorator for adding flexible argument handling to commands
  • process_args: Function to process command-line arguments into configuration
  • Loader: Click group class that loads commands from submodules and extensions

% end main

Metadata

Release files for moat-lib-run 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moat-lib-run 0.2.2
File Size Uploaded
moat_lib_run-0.2.2.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moat-lib-run 0.2.2
File Interpreter ABI Platform
moat_lib_run-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.0 kB

Release files / moat_lib_run-0.2.2.tar.gz

Download URL moat_lib_run-0.2.2.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c3ba19c8a840076711a9866ad15df1bc463c58cf5c73dd6868c12196e730b37f
BLAKE2b-256 checksum
How to use checksums
de41f365744e2b6fcca4675dd7b58bc1771e5d6d956dc49e65c93b82f9caa303
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / moat_lib_run-0.2.2-py3-none-any.whl

Download URL moat_lib_run-0.2.2-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33e62e86eaf0347755192c1e581ca819a8f60c37e706ebc1d1e773f16ceeaf08
BLAKE2b-256 checksum
How to use checksums
c56f19a988015f881627342db7bcd5789df7b4eda055a6c33501a2f546634caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

0.2.4

2 release files

0.2.3

2 release files

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page