Skip to main content

Muscles CLI runtime for shared command routing and strategy execution

Project description

Muscles CLI

muscles-cli is the console runtime for Muscles. It uses the same application shape as the HTTP runtimes: an ApplicationMeta class owns a Context, and the context delegates execution to CliStrategy.

Installation

pip install muscles-cli

Canonical ecosystem install matrix is documented in core: Muscles installation matrix.

Related Repositories

  • muscles - core contracts, actions, inspect output and canonical documentation.
  • muscles-asgi - ASGI runtime generated projects can target.
  • muscles-wsgi - WSGI runtime generated projects can target.
  • muscles-mcp - MCP projection over the same action contracts.
  • muscles-benchmarks - CLI regression and architecture checks.

Project Scaffolding

Use canonical command muscles new:

muscles new demo --runtime asgi
muscles new demo --runtime wsgi
muscles new demo --runtime cli

Notes:

  • muscular new is not a canonical command.
  • Existing non-empty directory is rejected unless --force is used.

AI Workflow Commands

muscles capabilities --json
muscles inspect --json --app app.application:App
muscles action list --app app.application:App --json
muscles action inspect bookings.echo --app app.application:App --json
muscles action run bookings.echo --app app.application:App --payload-json '{"title":"Call"}' --json
muscles routes --app app.application:App
muscles schemas --app app.application:App
muscles rules --app app.application:App
muscles cli --app app.application:App
muscles generate page Home --with-tests
muscles doctor --json
muscles test --doctor

Quick Start

from muscles import ApplicationMeta, Context, cli
from muscles.cli import CliStrategy


class App(metaclass=ApplicationMeta):
    context = Context(CliStrategy)

    def run(self, *args):
        return self.context.execute(*args, shutup=True)


@cli.group()
def bookings(*args):
    """Booking commands."""
    return True


@bookings.command(command_name="remove")
def remove_booking(*args):
    booking_id = args[0]
    return f"removed {booking_id}"


app = App()
assert app.run("bookings", "remove", "1") == "removed 1"

Routing Model

Groups and commands form a tree. That makes CLI routing close to HTTP routing:

  • bookings remove 1 is a nested route with an argument;
  • bookings/list can be normalized by an application before calling the CLI;
  • groups can have handlers, but returning True lets execution continue to a child command.

More detail: docs/routing.md.

Core Stream Output

English: CLI progress output uses core StreamEvent items from StreamResult. render_stream_result() can print human-readable progress/log and result lines, or machine-readable JSON lines. The CLI layer only owns presentation and exit code mapping; stream semantics stay in muscles.core.

Русский: CLI progress output использует core StreamEvent из StreamResult. render_stream_result() может печатать human-readable progress/log/result строки или machine-readable JSON lines. CLI слой отвечает только за presentation и exit code mapping; stream semantics остаётся в muscles.core.

Arguments

Use @cli.argument() for named arguments and @cli.flag() for boolean flags. Required prompted arguments use input() or getpass.getpass() when hidden.

For nested commands, define options on the parent group object:

@cli.group(command_name="bookings")
def bookings(*args):
    return True

@bookings.command(command_name="list")
@bookings.argument("--limit", nargs=1, default="25")
def bookings_list(*args, limit):
    return limit

Canonical invocations for benchmark/automation scripts:

bookings list --limit 10
bookings list --limit=10

Development

Run tests with the core package on PYTHONPATH:

PYTHONPATH=../muscles/src:src python -m pytest -q

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

muscles_cli-1.0.0.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

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

muscles_cli-1.0.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file muscles_cli-1.0.0.tar.gz.

File metadata

  • Download URL: muscles_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for muscles_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 120e209f094ba754fb7c568f599510a84750b074f3d02c286333cab152f6d5c7
MD5 b83e2615eb5d456f2d5cd2c0e4a3c285
BLAKE2b-256 f9fd80f1e239d4cfeef923e5e79f85ebb657408f2acc50cca11c903041a9d7bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for muscles_cli-1.0.0.tar.gz:

Publisher: release.yml on butkoden/muscles-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file muscles_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: muscles_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for muscles_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92a1fce751f3f1c73ab3a4e7e0c69904623b18f29e95ddf39beb9d0c62f36c06
MD5 232793c0b700594e74b6f9d473686005
BLAKE2b-256 759ae175f5cd1cac9810e3dab88e5c62a3907b9878eef746e4ff9ce943327e0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for muscles_cli-1.0.0-py3-none-any.whl:

Publisher: release.yml on butkoden/muscles-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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