mirror of
https://github.com/kbenestad/mdcms.git
synced 2026-06-18 07:24:31 +00:00
Bump CLI to v0.3.1, add banner fetch to --version
- CLI_VERSION → 0.3.1, CLI_RELEASE_DATE → 10 May 2026
- Replace click.version_option with custom callback that prints version
+ release date, then fetches docs/banner/v{VERSION}.txt from GitHub
and prints it; falls back to a "no online information" message on 404
or network error
- Add versioning rule to CLAUDE.md
https://claude.ai/code/session_015XtsgTMi8UtmgxEgb5Qt2c
This commit is contained in:
parent
767b370202
commit
b1fc97a024
2 changed files with 30 additions and 4 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Versioning rule
|
||||
|
||||
**Always update `CLI_VERSION` and `CLI_RELEASE_DATE` in `mdcms.py` before producing a new version of the file.** After each change to `mdcms.py`, ask the user: "Will this be a new release?" If yes, bump `CLI_VERSION` (and `version` in `pyproject.toml`) before committing.
|
||||
|
||||
## Branching convention
|
||||
|
||||
- **Code changes** (`mdcms.py`, `pyproject.toml`, `app/`, `.github/`) — use branch `mdcms_cli` (create from `main` if it doesn't exist), PR to `main`.
|
||||
|
|
|
|||
30
mdcms.py
30
mdcms.py
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# mdcms v0.3 — CLI companion
|
||||
# mdcms v0.3.1 — CLI companion
|
||||
#
|
||||
# Copyright 2026 Kristian Benestad
|
||||
# Apache License, Version 2.0 — https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
"""MD-CMS v0.3 — CLI tool for managing and building MD-CMS sites."""
|
||||
"""MD-CMS v0.3.1 — CLI tool for managing and building MD-CMS sites."""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
|
@ -20,7 +20,8 @@ import certifi
|
|||
import click
|
||||
import yaml
|
||||
|
||||
CLI_VERSION = "0.3"
|
||||
CLI_VERSION = "0.3.1"
|
||||
CLI_RELEASE_DATE = "10 May 2026"
|
||||
MIN_SUPPORTED_VERSION = "0.3"
|
||||
|
||||
MARKER_RE = re.compile(r"mdcms v(\d+\.\d+)", re.IGNORECASE)
|
||||
|
|
@ -467,8 +468,29 @@ def download_template(dest: Path):
|
|||
|
||||
# ─── CLI commands ─────────────────────────────────────────────
|
||||
|
||||
def _version_callback(ctx, param, value):
|
||||
if not value or ctx.resilient_parsing:
|
||||
return
|
||||
click.echo(f"mdcms v{CLI_VERSION} (released {CLI_RELEASE_DATE})")
|
||||
url = f"https://raw.githubusercontent.com/kbenestad/mdcms/refs/heads/main/docs/banner/v{CLI_VERSION}.txt"
|
||||
try:
|
||||
ssl_ctx = ssl.create_default_context(cafile=certifi.where())
|
||||
req = urllib.request.Request(url, headers={"User-Agent": f"mdcms/{CLI_VERSION}"})
|
||||
with urllib.request.urlopen(req, context=ssl_ctx, timeout=5) as resp:
|
||||
click.echo(resp.read().decode("utf-8").strip())
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.code == 404:
|
||||
click.echo("There is no online information defined for this version.")
|
||||
else:
|
||||
click.echo("There is no online information defined for this version.")
|
||||
except Exception:
|
||||
click.echo("There is no online information defined for this version.")
|
||||
ctx.exit()
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.version_option(CLI_VERSION, prog_name="mdcms")
|
||||
@click.option("--version", is_flag=True, is_eager=True, expose_value=False,
|
||||
callback=_version_callback, help="Show version and exit.")
|
||||
def cli():
|
||||
"""MD-CMS — Markdown-based CMS companion CLI.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue