From 66c2314f9cc6b269fad973a35b31a3d746153104 Mon Sep 17 00:00:00 2001 From: Isabel Date: Mon, 20 May 2024 12:33:13 +0100 Subject: [PATCH] fix: argument `--accent` behaves like the old argument (#200) * fix: argument --accent behaves like the old argument * fix: seprate arg for all accents * fix: logger accurracy * ci: call correct build arg --- .github/workflows/release.yml | 8 ++-- build.py | 80 +++++++++++++++++------------------ 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c878efbe..e36ed534 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,10 +22,10 @@ jobs: run: sudo apt update && sudo apt install -y sassc inkscape optipng - name: Generate themes run: | - python ./build.py mocha -a all --zip -d $PWD/releases && - python ./build.py macchiato -a all --zip -d $PWD/releases && - python ./build.py frappe -a all --zip -d $PWD/releases && - python ./build.py latte -a all --zip -d $PWD/releases + python ./build.py mocha --all-accents --zip -d $PWD/releases && + python ./build.py macchiato --all-accents --zip -d $PWD/releases && + python ./build.py frappe --all-accents --zip -d $PWD/releases && + python ./build.py latte --all-accents --zip -d $PWD/releases - name: Add zips to release uses: softprops/action-gh-release@v2 with: diff --git a/build.py b/build.py index 28c9738a..d125e946 100755 --- a/build.py +++ b/build.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python3 +#!/usr/bin/env python3 import os, re, shutil, subprocess, argparse, glob, logging, zipfile from dataclasses import dataclass @@ -525,7 +525,8 @@ def parse_args(): "-a", type=str, default="mauve", - dest="accent", + nargs='+', + dest="accents", choices=[ "rosewater", "flamingo", @@ -541,11 +542,17 @@ def parse_args(): "sapphire", "blue", "lavender", - "all", ], help="Accent of the theme.", ) + parser.add_argument( + "--all-accents", + help="Whether to build all accents", + dest="all_accents", + action="store_true", + ) + parser.add_argument( "--size", "-s", @@ -598,44 +605,35 @@ def main(): tweaks = Tweaks(tweaks=args.tweaks) palette = getattr(PALETTE, args.flavor) - accents = [ - "rosewater", - "flamingo", - "pink", - "mauve", - "red", - "maroon", - "peach", - "yellow", - "green", - "teal", - "sky", - "sapphire", - "blue", - "lavender", - ] - - if args.accent == "all": - for accent in accents: - accent = getattr(palette.colors, accent) - - ctx = BuildContext( - build_root=args.dest, - theme_name=args.name, - flavor=palette, - accent=accent, - size=args.size, - tweaks=tweaks, - output_format=output_format, - ) - tweaks_temp() - gnome_shell_version() - build_theme(ctx) - logger.info("Done!") - else: - accent = getattr(palette.colors, args.accent) + accents = args.accents + if args.all_accents: + accents = [ + "rosewater", + "flamingo", + "pink", + "mauve", + "red", + "maroon", + "peach", + "yellow", + "green", + "teal", + "sky", + "sapphire", + "blue", + "lavender", + ] + + for accent in accents: + accent = getattr(palette.colors, accent) + tweaks = Tweaks(tweaks=args.tweaks) + + if args.zip: + output_format = "zip" + else: + output_format = "dir" ctx = BuildContext( build_root=args.dest, theme_name=args.name, @@ -645,15 +643,15 @@ def main(): tweaks=tweaks, output_format=output_format, ) - logger.info("Building temp tweaks file") tweaks_temp() logger.info("Inserting gnome-shell imports") gnome_shell_version() logger.info("Building main theme") build_theme(ctx) - logger.info("Done!") + logger.info(f"Completed {palette.identifier} with {accent.identifier}") + logger.info("Done!") try: main()