Skip to content

Commit 24aa859

Browse files
committed
refactor: simplify paragon_build_tokens command by using context args
1 parent 9a62a17 commit 24aa859

File tree

1 file changed

+6
-52
lines changed

1 file changed

+6
-52
lines changed

plugins/tutor-contrib-paragon/tutorparagon/commands.py

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,13 @@
99
import click
1010

1111

12-
@click.command()
13-
@click.option(
14-
"--source-tokens-only",
15-
is_flag=True,
16-
default=False,
17-
help="Include only source design tokens in the build.",
12+
@click.command(
13+
context_settings=dict(ignore_unknown_options=True, allow_extra_args=True)
1814
)
19-
@click.option(
20-
"--output-token-references/--no-output-token-references",
21-
default=True,
22-
help="Include references for tokens with aliases to other tokens in the build.",
23-
)
24-
@click.option(
25-
"--exclude-core",
26-
is_flag=True,
27-
default=False,
28-
help="Exclude core from the token build.",
29-
)
30-
@click.option("--themes", help="Comma-separated list of themes to build.")
31-
@click.option(
32-
"-v", "--verbose", is_flag=True, default=False, help="Enable verbose logging."
33-
)
34-
def paragon_build_tokens(
35-
source_tokens_only: bool,
36-
output_token_references: bool,
37-
exclude_core: bool,
38-
themes: str,
39-
verbose: bool,
40-
) -> list[tuple[str, str]]:
15+
@click.pass_context
16+
def paragon_build_tokens(ctx: click.Context) -> list[tuple[str, str]]:
4117
"""
4218
Build theme token files using Paragon.
43-
44-
Args:
45-
source_tokens_only (bool): Only source design tokens.
46-
output_token_references (bool): Output token references.
47-
exclude_core (bool): Exclude core from the token build.
48-
themes (str): Comma-separated list of themes.
49-
verbose (bool): Verbose logging.
50-
51-
Returns:
52-
list[tuple[str, str]]: List of commands to run.
19+
Accepts and forwards all options/arguments to paragon-builder.
5320
"""
54-
args = []
55-
if source_tokens_only:
56-
args.append("--source-tokens-only")
57-
if not output_token_references:
58-
args.append("--output-references=false")
59-
if exclude_core:
60-
args.append("--exclude-core")
61-
if themes:
62-
args.append("--themes")
63-
args.append(themes)
64-
if verbose:
65-
args.append("--verbose")
66-
67-
return [("paragon-builder", " ".join(args))]
21+
return [("paragon-builder", " ".join(ctx.args))]

0 commit comments

Comments
 (0)