Skip to content

Commit ea320f0

Browse files
committed
Initial commit — codechu-cli 0.1.0
Stdlib-only CLI primitives for consistent UX across Codechu tools. Static helpers - Color: ANSI palette with NO_COLOR + TTY detection - banner(): single-line interactive header - ascii_banner() + LOGOS: multi-line art banner with optional color, TTY-gated by default; ships a Codechu logo - resolve_format(): TTY → table / pipe → json defaults - format_examples(): argparse epilog formatter Animated & input-accepting - ProgressLine: single-line overwriting stderr progress - ProgressBar: bracketed bar with totals - Spinner: braille frames (ASCII fallback when LANG=C / TERM=dumb), thread-driven, context-manager friendly - confirm(): yes/no with TTY + assume_yes short-circuit - prompt(): text input with validation; password mode via getpass - select() / multiselect(): arrow-key pickers via termios + tty; graceful numbered-prompt fallback on Windows or non-TTY Emoji helpers - capabilities(): detects unicode / color / emoji from LANG + TERM + NO_COLOR + CODECHU_CLI_EMOJI env override - e(name, fallback=...): glyph lookup with ASCII fallback for ok/fail/ warn/info/arrow/bullet/check_on/check_off/scan/trash/broom/disk/watch 61 tests pass with ≥88% coverage. Pure stdlib, no dependencies. Python 3.10+. MIT. POSIX-first with Windows-degraded interactive components. Designed for extraction-readiness from disk_cleaner.cli_helpers; same API + extended interactive surface.
0 parents  commit ea320f0

28 files changed

Lines changed: 2213 additions & 0 deletions

‎.gitattributes‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Otomatik LF normalize: tüm metin dosyaları depo'da LF, checkout'ta OS-default
2+
* text=auto eol=lf
3+
4+
# Binary — diff/merge yapma
5+
*.png binary
6+
*.jpg binary
7+
*.jpeg binary
8+
*.gif binary
9+
*.ico binary
10+
*.db binary
11+
*.sqlite binary
12+
13+
# Python: linguist-language
14+
*.py linguist-language=Python

‎.github/workflows/ci.yml‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- run: pip install -e ".[dev]"
22+
- run: ruff check src tests
23+
- run: pytest -q --cov=codechu_cli --cov-report=term-missing --cov-fail-under=85

‎.github/workflows/release.yml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.12"
18+
- name: Install build + twine
19+
run: pip install --upgrade build twine
20+
- name: Build sdist + wheel
21+
run: python -m build
22+
- name: Validate metadata
23+
run: python -m twine check dist/*
24+
- name: Upload to PyPI
25+
env:
26+
TWINE_USERNAME: __token__
27+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
28+
run: python -m twine upload dist/*

‎.gitignore‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
__pycache__/
2+
*.py[cod]
3+
*.egg-info/
4+
build/
5+
dist/
6+
.venv/
7+
.pytest_cache/
8+
.ruff_cache/
9+
.coverage
10+
htmlcov/
11+
.tox/
12+
.mypy_cache/
13+
14+
# OS / IDE
15+
.DS_Store
16+
.vscode/
17+
.idea/
18+
.cursor/
19+
20+
# Credentials safety net
21+
.env
22+
*.key
23+
*.pem
24+
*.token

‎CHANGELOG.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Changelog
2+
3+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) + [SemVer](https://semver.org/).
4+
5+
## [Unreleased]
6+
7+
## [0.1.0] - 2026-05-20
8+
9+
### Added
10+
- Initial extraction from [codechu/disk-cleaner](https://github.com/codechu/disk-cleaner)
11+
- `Color` — ANSI palette with `NO_COLOR` + TTY detection
12+
- `ProgressLine` — single-line overwriting stderr progress
13+
- `ProgressBar(total, ...)` — bracketed progress bar with percent + counts
14+
- `Spinner(message, ...)` — threaded spinner, braille frames with ASCII fallback
15+
- `confirm()` — yes/no prompt with TTY / `assume_yes` short-circuit
16+
- `prompt()` — single-line input with optional validator + password mode
17+
- `select()` — single-choice picker (arrow keys on TTY, numbered fallback)
18+
- `multiselect()` — multi-choice picker (space toggle, `a` select-all)
19+
- `banner()` — single-line interactive header
20+
- `resolve_format()` — TTY vs pipe default format chooser
21+
- `format_examples()` — argparse epilog formatter
22+
- `emoji.capabilities()` + `emoji.e()` — locale + terminal-aware glyph lookup

‎CLAUDE.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CLAUDE.md — codechu-cli
2+
3+
Bootstrap per `codechu-org/ai/AGENTS.md` §0 before any work. Prefer
4+
the local clone at `$org_home/codechu-org/ai/AGENTS.md` (if
5+
`~/.config/codechu/config.toml` has `org_home` set); otherwise
6+
WebFetch the public raw URL
7+
<https://raw.githubusercontent.com/codechu/codechu-org/main/ai/AGENTS.md>.
8+
This file lists only product-local overrides.
9+
10+
## Product-local notes
11+
12+
- Pure-Python, stdlib-only. No GTK, no curses, no third-party
13+
runtime dependencies. Tests in `tests/` must keep that invariant.
14+
- POSIX-first. Raw-mode features (`select`, `multiselect`) detect
15+
non-TTY / Windows up front and fall back to numbered prompts —
16+
do not add a hard `termios` import at module top.
17+
- Public API surface: see `codechu_cli.__all__`. Anything else
18+
(private helpers, frame constants) is internal.
19+
- Coverage target: ≥85 %.
20+
- Emoji defaults are conservative ("temkinli") — when `LANG=C` or
21+
`TERM=dumb`, fall back to ASCII glyphs. `CODECHU_CLI_EMOJI=always`
22+
forces on, `never` forces off.
23+
24+
## Discipline reminders (org rules apply)
25+
26+
- Conventional Commits, no AI signature.
27+
- No `--no-verify`, no force push, no unapproved publish.
28+
- See `codechu-org/ai/AGENTS.md` for the full list.

‎CODE_OF_CONDUCT.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Code of Conduct
2+
3+
This project adopts the [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
4+
5+
## Summary
6+
7+
- Be respectful, inclusive, and patient.
8+
- Assume good faith; when giving criticism, focus on the work, not the person.
9+
- Harassment, personal attacks, and discriminatory language are not accepted in any form.
10+
- Repo maintainers have the authority to enforce these rules;
11+
comments / PRs / issues that violate them may result in a warning, lock, or ban.
12+
13+
## Enforcement
14+
15+
If you believe the rules have been violated:
16+
17+
- Write to `info@codechu.com`, or
18+
- Send a private mention to the `@codechu/maintainers` team in the repo
19+
20+
All reports are handled confidentially. The maintainer team does its
21+
best to respond in a reasonable time (best-effort, open-source project —
22+
no fixed SLA).
23+
24+
Full text: [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/)

‎CONTRIBUTING.md‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Contributing to codechu-cli
2+
3+
Thanks for thinking about contributing. `codechu-cli` is a small,
4+
focused CLI primitives library — pure stdlib, POSIX-first. Patches
5+
that keep that invariant intact are warmly received.
6+
7+
This library was originally extracted from [Disk Cleaner](https://github.com/codechu/disk-cleaner),
8+
but is maintained independently with its own release cadence.
9+
10+
## Development setup
11+
12+
```bash
13+
git clone https://github.com/codechu/cli-py.git
14+
cd cli-py
15+
pip install -e ".[dev]"
16+
pytest -q
17+
ruff check src tests
18+
```
19+
20+
## Workflow
21+
22+
- Branch names: `feature/<short>`, `fix/<short>`, `refactor/<short>`,
23+
`docs/<short>`, `test/<short>`.
24+
- Commit messages: [Conventional Commits](https://www.conventionalcommits.org/)
25+
(`feat:`, `fix:`, `refactor:`, `docs:`, `test:`, `chore:`).
26+
- Open a PR using the template; describe the *why* in the body.
27+
- One change per PR — keep diffs reviewable.
28+
29+
## Bug reports
30+
31+
A useful bug report includes:
32+
33+
- Python version + OS + terminal emulator (`$TERM`, `$LANG`).
34+
- A minimal reproducer (≤30 lines, stdlib-only if possible).
35+
- Expected vs observed behaviour. For TTY/non-TTY differences,
36+
mention whether you ran under a pty, a CI runner, or a real shell.
37+
38+
## Tests
39+
40+
- `pytest -q` must pass; coverage stays at **≥85 %**.
41+
- New feature → new test. Interactive components (`select`,
42+
`multiselect`, `Spinner`) need tests that bypass the raw-mode
43+
path — use non-TTY streams + monkeypatched `time.sleep`.
44+
- Don't introduce real sleeps for synchronization — mock `time`.
45+
- Prefer `io.StringIO` for stream injection over touching real fds.
46+
47+
## Public API discipline
48+
49+
The public surface is what `codechu_cli.__all__` exports. Everything
50+
else is internal — please don't extend it without a discussion first.
51+
52+
## Style
53+
54+
- `ruff check` + `ruff format` clean.
55+
- Type hints on public APIs (`from __future__ import annotations`).
56+
- Use `logging.getLogger(__name__)`; avoid `print`.
57+
- Pure stdlib — no new third-party runtime dependencies.
58+
59+
## Security
60+
61+
If you find a security issue, see [SECURITY.md](SECURITY.md) — do not
62+
open a public issue for it.

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Codechu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)