Cli tool #9

Merged
Zacharias-Brohn merged 33 commits from cli-tool into main 2026-02-22 21:43:51 +01:00
Showing only changes of commit cfa1902797 - Show all commits
+5 -11
View File
@@ -2,6 +2,7 @@ from typing import Annotated, Optional
import typer import typer
import json import json
from importlib import resources
from pathlib import Path from pathlib import Path
from PIL import Image from PIL import Image
from materialyoucolor.quantize import QuantizeCelebi from materialyoucolor.quantize import QuantizeCelebi
@@ -65,7 +66,7 @@ def generate(
f"Invalid hex color '{s}' (expected 6 hex digits, optionally prefixed with '#').") f"Invalid hex color '{s}' (expected 6 hex digits, optionally prefixed with '#').")
return f"#{s.upper()}" return f"#{s.upper()}"
def parse_preset_file(file_path: Path) -> dict: def parse_preset_file(file_path) -> dict:
""" """
Parse a preset scheme file with lines like: Parse a preset scheme file with lines like:
primary_paletteKeyColor 6a73ac primary_paletteKeyColor 6a73ac
@@ -168,19 +169,12 @@ def generate(
try: try:
if preset: if preset:
# try local presets directory: presets/<preset>/<flavour>.txt or presets/<preset>-<flavour>.txt # try local presets directory: presets/<preset>/<flavour>.txt or presets/<preset>-<flavour>.txt
base1 = Path("zshell") / "assets" / "schemes" / \ base = resources.files("zshell.assets.schemes")
preset / flavour / f"{mode}.txt" preset_path = base / preset / flavour / f"{mode}.txt"
if base1.exists():
preset_path = base1
else:
raise FileNotFoundError(
f"Preset file not found. Looked for: {base1.resolve()}. "
"You can also pass --preset-file <path> directly."
)
mapping = parse_preset_file(preset_path) mapping = parse_preset_file(preset_path)
generate_color_scheme_from_preset( generate_color_scheme_from_preset(
mapping, output, preset or preset_path.stem, flavour) mapping, output, preset, flavour)
typer.echo(f"Wrote preset-based scheme to {output}") typer.echo(f"Wrote preset-based scheme to {output}")
raise typer.Exit() raise typer.Exit()