Configurable CLI report asyoulikeit for Python projects.
Project description
asyoulikeit
--as tsv | json | display→ as you like it
Multi-format report output for Python CLIs — JSON for machines, TSV for pipes, display for humans.
Quickstart
Write a handler that returns a Reports object and decorate it with @tabulated_output:
"""Quickstart example: list a handful of programming languages as a Report.
Run this file directly to see the default display format:
python scripts/examples/quickstart.py
Or force a specific format:
python scripts/examples/quickstart.py --as tsv
python scripts/examples/quickstart.py --as json
The ``scripts/generate_readme.py`` generator imports this file, invokes the
command with each built-in format, and injects the source + captured outputs
into the README.
"""
import click
from asyoulikeit import (
Importance,
Report,
Reports,
TabularData,
tabulated_output,
)
@click.command()
@tabulated_output
def list_languages():
"""List some well-known programming languages."""
data = (
TabularData(
title="Programming languages",
description="A small sample of notable programming languages.",
)
.add_column("name", "Name")
.add_column("year", "Year")
.add_column("paradigm", "Paradigm")
.add_column("typing", "Typing", importance=Importance.DETAIL)
.add_row(name="Python", year=1991, paradigm="Multi-paradigm", typing="Dynamic, duck")
.add_row(name="Haskell", year=1990, paradigm="Functional", typing="Static, inferred")
.add_row(name="Go", year=2009, paradigm="Imperative", typing="Static, structural")
)
return Reports(languages=Report(data=data))
if __name__ == "__main__":
list_languages()
The decorator injects --as, --report, --header/--no-header, and --detailed/--essential options into the command. --as defaults to display when stdout is a terminal, tsv when piped.
--as tsv
# Name Year Paradigm
Python 1991 Multi-paradigm
Haskell 1990 Functional
Go 2009 Imperative
--as json
{
"tables": {
"languages": {
"metadata": {
"title": "Programming languages",
"description": "A small sample of notable programming languages.",
"present_transposed": false
},
"columns": [
{
"key": "name",
"label": "Name",
"header": false
},
{
"key": "year",
"label": "Year",
"header": false
},
{
"key": "paradigm",
"label": "Paradigm",
"header": false
},
{
"key": "typing",
"label": "Typing",
"header": false
}
],
"rows": [
{
"name": "Python",
"year": 1991,
"paradigm": "Multi-paradigm",
"typing": "Dynamic, duck"
},
{
"name": "Haskell",
"year": 1990,
"paradigm": "Functional",
"typing": "Static, inferred"
},
{
"name": "Go",
"year": 2009,
"paradigm": "Imperative",
"typing": "Static, structural"
}
]
}
}
}
--as display
Programming languages
┏━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃ Name ┃ Year ┃ Paradigm ┃ Typing ┃
┡━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
│ Python │ 1991 │ Multi-paradigm │ Dynamic, duck │
│ Haskell │ 1990 │ Functional │ Static, inferred │
│ Go │ 2009 │ Imperative │ Static, structural │
└─────────┴──────┴────────────────┴────────────────────┘
A small sample of notable programming languages.
License
MIT — see LICENSE.
This README is generated by scripts/generate_readme.py from scripts/readme_template.md.j2 and scripts/examples/. Do not edit directly; re-run the generator after any change.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asyoulikeit-0.2.1.tar.gz.
File metadata
- Download URL: asyoulikeit-0.2.1.tar.gz
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d009213d1738df1b109d2ae3ff0ff4bea99713ff8204393cfb23d82f5645f00
|
|
| MD5 |
a4828dfb188e58e25368edf904aaa97a
|
|
| BLAKE2b-256 |
8d164560e6deb66b1c81a44aa0a9df9d8dbaae1181ff15f2b7fec921d545d206
|
File details
Details for the file asyoulikeit-0.2.1-py3-none-any.whl.
File metadata
- Download URL: asyoulikeit-0.2.1-py3-none-any.whl
- Upload date:
- Size: 24.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d20ab34f9d7ebfeb23356964cafb36b35e99a2c76116bb9847443b6af35b6d9
|
|
| MD5 |
c291769777baa25e04e70035d9466e13
|
|
| BLAKE2b-256 |
8d763556ae7c4b7694ad0f55aec167d6a8452711eac1b1386cc657c53e9b472b
|