feat: add cli for svg render
This commit is contained in:
@@ -1,18 +1,23 @@
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .assemblicon.context import Prerequisite, Context, AdvancedContext, SvgRenderKind
|
from .assemblicon.context import Prerequisite, Context, AdvancedContext
|
||||||
from .assemblicon.utils import setup_logging
|
from .assemblicon.utils import setup_logging
|
||||||
from .std_icons import build_standard_icons
|
from .std_icons import build_standard_icons
|
||||||
from .nostd_icons import build_non_standard_icons
|
from .nostd_icons import build_non_standard_icons
|
||||||
|
from .cli import parse
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
opts = parse()
|
||||||
|
|
||||||
setup_logging()
|
setup_logging()
|
||||||
|
|
||||||
repository_root = Path(__file__).resolve().parent.parent.parent.parent
|
repository_root = Path(__file__).resolve().parent.parent.parent.parent
|
||||||
iconset_input = repository_root / "src"
|
iconset_input = repository_root / "src"
|
||||||
iconset_output = repository_root / "artifact"
|
iconset_output = repository_root / "artifact"
|
||||||
prereq = Prerequisite(iconset_input, iconset_output, SvgRenderKind.Inkscape)
|
prereq = Prerequisite(
|
||||||
|
iconset_input, iconset_output, opts.svg_render.to_assemblicon_type()
|
||||||
|
)
|
||||||
ctx = Context(prereq)
|
ctx = Context(prereq)
|
||||||
advctx = AdvancedContext(ctx)
|
advctx = AdvancedContext(ctx)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import argparse
|
||||||
|
import enum
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from .assemblicon import artrender
|
||||||
|
|
||||||
|
|
||||||
|
class SvgRender(enum.StrEnum):
|
||||||
|
Inkscape = "inkscape"
|
||||||
|
ReSvg = "resvg"
|
||||||
|
|
||||||
|
def to_assemblicon_type(self) -> artrender.SvgRenderKind:
|
||||||
|
match self:
|
||||||
|
case SvgRender.Inkscape:
|
||||||
|
return artrender.SvgRenderKind.Inkscape
|
||||||
|
case SvgRender.ReSvg:
|
||||||
|
return artrender.SvgRenderKind.ReSvg
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class Cli:
|
||||||
|
svg_render: SvgRender
|
||||||
|
|
||||||
|
|
||||||
|
def parse() -> Cli:
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
prog="Aurora Icon Set Builder",
|
||||||
|
description="The Programmatic Icon Assembly Workflow for Aurora Icon Set.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-s",
|
||||||
|
"--svg-render",
|
||||||
|
dest="svg_render",
|
||||||
|
action="store",
|
||||||
|
type=SvgRender,
|
||||||
|
default=SvgRender.Inkscape,
|
||||||
|
help="The render used for rendering SVG into PNG.",
|
||||||
|
metavar="RENDER",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
return Cli(
|
||||||
|
svg_render=args.svg_render,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user