Skip to main content

Main command entry point infrastructure for MoaT applications

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moat_lib_run-0.1.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moat_lib_run-0.1.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file moat_lib_run-0.1.1.tar.gz.

File metadata

  • Download URL: moat_lib_run-0.1.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for moat_lib_run-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a91cd5e98bb590afdd0ee7a3e8c7661ec289a449dba67b4c5443246b3794c103
MD5 0fa56c675faef6a96a2e10081feddc1a
BLAKE2b-256 6db9f2552b9cd38995c53aecc4e1dbcbbcbe938a646f4426d5524be279881241

See more details on using hashes here.

File details

Details for the file moat_lib_run-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: moat_lib_run-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for moat_lib_run-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 254bf0abb5105c68e8dbe8caa0c8291add3946d5a09e8b5174956892e2697d9f
MD5 88acb3174c0a54e3cb7405c6b18e25f5
BLAKE2b-256 e9252c7daca74daa2d05f8ce0773ebeb3fd2c25f19a161317618546b15ca2981

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page