Skip to content

Commit

Permalink
Add filter option to generate (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
therve authored Aug 23, 2022
1 parent cb0c3b7 commit 55cd378
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apigentools/commands/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@
default=False,
help="Delete generated files in output_dir before generation",
)
@click.option(
"--filter-sections",
help="Specify spec sections to filter out from the output",
default=env_or_val("APIGENTOOLS_FILTER_SECTIONS", (), __type=list),
multiple=True,
)
@click.pass_context
def generate(ctx, **kwargs):
"""Generate client code"""
Expand Down Expand Up @@ -243,6 +249,7 @@ def run(self):
fs_files = set()

# first, generate full spec for all major versions of the API
filter_sections = frozenset(self.args.get("filter_sections", ()))
for language, version, fs_file in self.yield_lang_version_specfile():
info[language][version] = fs_file

Expand All @@ -257,6 +264,7 @@ def run(self):
version,
self.config.get_language_config(language).spec_sections_for(version),
fs_file,
filter_sections,
)
log.info(f"Generated {fs_file} for {language}/{version}")

Expand Down

0 comments on commit 55cd378

Please sign in to comment.