mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
allow for passing arguments to generators
This commit is contained in:
parent
386ce3a4c1
commit
29462a5047
1 changed files with 33 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import gen_py_pytest_data_paths
|
import gen_py_pytest_data_paths
|
||||||
|
@ -11,15 +12,39 @@ CWD = Path(__file__).parent
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
items = [
|
parser = argparse.ArgumentParser(description="Run code generators")
|
||||||
(gen_py_schema_exports.main, "schema exports"),
|
parser.add_argument(
|
||||||
(gen_ts_types.main, "frontend types"),
|
"generators",
|
||||||
(gen_ts_locales.main, "locales"),
|
nargs="*",
|
||||||
(gen_py_pytest_data_paths.main, "test data paths"),
|
help="Specific generators to run (schema, types, locales, data-paths, routes). If none specified, all will run.", # noqa: E501 - long line
|
||||||
(gen_py_pytest_routes.main, "pytest routes"),
|
)
|
||||||
]
|
args = parser.parse_args()
|
||||||
|
|
||||||
for func, name in items:
|
# Define all available generators
|
||||||
|
all_generators = {
|
||||||
|
"schema": (gen_py_schema_exports.main, "schema exports"),
|
||||||
|
"types": (gen_ts_types.main, "frontend types"),
|
||||||
|
"locales": (gen_ts_locales.main, "locales"),
|
||||||
|
"data-paths": (gen_py_pytest_data_paths.main, "test data paths"),
|
||||||
|
"routes": (gen_py_pytest_routes.main, "pytest routes"),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Determine which generators to run
|
||||||
|
if args.generators:
|
||||||
|
# Validate requested generators
|
||||||
|
invalid_generators = [g for g in args.generators if g not in all_generators]
|
||||||
|
if invalid_generators:
|
||||||
|
log.error(f"Invalid generator(s): {', '.join(invalid_generators)}")
|
||||||
|
log.info(f"Available generators: {', '.join(all_generators.keys())}")
|
||||||
|
return
|
||||||
|
|
||||||
|
generators_to_run = [(all_generators[g][0], all_generators[g][1]) for g in args.generators]
|
||||||
|
else:
|
||||||
|
# Run all generators (default behavior)
|
||||||
|
generators_to_run = list(all_generators.values())
|
||||||
|
|
||||||
|
# Run the selected generators
|
||||||
|
for func, name in generators_to_run:
|
||||||
log.info(f"Generating {name}...")
|
log.info(f"Generating {name}...")
|
||||||
func()
|
func()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue