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

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

Built distribution (wheel)

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

Total release size: 26.1 kB

Release files / moat_lib_run-0.2.3.tar.gz

Download URL moat_lib_run-0.2.3.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
19ab8ca38309c9659897ca0de33b55285b947030e76bd1417f9fdb27ed4f46f1
BLAKE2b-256 checksum
How to use checksums
e6bcf16125635f2b069365c472adbd91df6c33bd4c4f2d14728553c7d50c7d3a
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.3-py3-none-any.whl

Download URL moat_lib_run-0.2.3-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4554853b32538e82180b5177fb2c0dcfbe18db400bf64f3d9d3701d673c98328
BLAKE2b-256 checksum
How to use checksums
364ddee991b8731b22cc42c38abb42b8976c78290947da8ae4bdfc19f7f41099
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

This release

0.2.3 This release

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