Registry / devops / craft-cli

craft-cli

JSON →
library3.4.1pypypi✓ verified 85d ago

A Python framework from Canonical for building CLI tools with structured output, logging, and progress indicators. Current version 3.4.0, requires Python >=3.10. Released on a monthly cadence.

pip install craft-cli
INSTALL
IMPORT
SIG · CRAFT-CLI
C
craft-cli
devopspythonv3.4.1
Install
1.9s avg
Import
134ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.140s · 19.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.128s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

craft_cli
import craft_cli
EmitterMode
from craft_cli import EmitterMode
from craft_cli.emitter import EmitterMode
EmitterMode is exported from the top-level package, not a submodule.
emit
from craft_cli import emit
from craft_cli.emitter import emit
emit is a top-level singleton, not from internal modules.

Initialize the emitter and use basic output functions.

from craft_cli import emit, EmitterMode # Initialize the CLI emitter emit.init(EmitterMode.BRIEF, appname="myapp") # Simple message emit.message("Hello, world!") # Progress bar with emit.open_stream("Processing") as stream: for i in range(10): stream.progress(f"Step {i+1}") # Error handling emit.error("Something went wrong")
craft --version
Debug
Known issues
breakingIn version 2.x, craft_cli was internally called CraftCLI but later renamed to craft_cli. Ensure imports use lowercase.
fix
Use lowercase 'craft_cli' throughout.
affects: >=2.0.0
deprecatedEmitterMode.BRIEF is considered legacy; prefer EmitterMode.VERBOSE or EmitterMode.QUIET for production.
fix
Use EmitterMode.VERBOSE for detailed output, EmitterMode.QUIET for minimal output.
affects: >=3.0.0
gotchaCalling emit.init() more than once without emit.cleanup() will raise a RuntimeError.
fix
Always pair emit.init() with emit.cleanup() in a try/finally block or context manager.
affects: all
gotchaThe appname argument in emit.init() must not contain spaces; otherwise, output formatting may break.
fix
Use a single word or hyphenated name for appname.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'craft_cli'
Package not installed or wrong import path (e.g., 'craft-cli' with hyphen).
fix
Install with 'pip install craft-cli' and import as 'craft_cli' (underscore).
RuntimeError: Emitter already initialized
emit.init() called twice without emit.cleanup() in between.
fix
Wrap code in try/finally: emit.init(...); try: ... finally: emit.cleanup().
AttributeError: module 'craft_cli' has no attribute 'emit'
Old import pattern or using incorrect casing.
fix
Use 'from craft_cli import emit'.
Upgrade
Version history
3.4.1latest on PyPI · released Jun 17, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
craft-cli — pip install craft-cli · libregistry