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.4

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.4
File Size Uploaded
moat_lib_run-0.2.4.tar.gz 14.3 kB Details

Built distribution (wheel)

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

Total release size: 26.2 kB

Release files / moat_lib_run-0.2.4.tar.gz

Download URL moat_lib_run-0.2.4.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d4d0c09bfb02228a5d29813ee6ce0901eac592c22a5da2b0b6a4aa1e3ee4e29f
BLAKE2b-256 checksum
How to use checksums
2ca581d09b6238c749f3ee8debdf9d69027ba8a47a9c7f22a7e2426197117d69
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.4-py3-none-any.whl

Download URL moat_lib_run-0.2.4-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4ab8ac3c9e9c9afd8fed762867d422962b6e230e46b3fb18c95dee058d768bb
BLAKE2b-256 checksum
How to use checksums
65b7fb03c85cea35003fddd2ab5e02ca62abecd8060e33a8ae35e4200188283e
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

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

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