diff --git a/run_recipe.py b/run_recipe.py index 0102499..09d0f7d 100644 --- a/run_recipe.py +++ b/run_recipe.py @@ -5,6 +5,7 @@ import os import shutil import argparse +import subprocess import traceback import threading @@ -282,6 +283,11 @@ def process_recipe(options): recipe = yaml.unsafe_load(f.read()) + if options.lint_recipe: + # Just run yamllint in a subprocess for now. This also provides a nicely colored output. + subprocess.run(['yamllint', options.recipe]) + exit() + if options.dump_recipe or options.dump_recipe_only: output = dump(recipe, Dumper=Dumper) terminal_size = shutil.get_terminal_size() @@ -365,6 +371,7 @@ def parse_arguments(arguments): parser.add_argument('--dump-recipe', action='store_true', default=False, help='Dump the loaded recipe; useful for finding errors in the recipe') parser.add_argument('--dump-recipe-only', action='store_true', default=False, help='Dump the loaded recipe and exit; useful for finding errors in the recipe') + parser.add_argument('--lint-recipe', action='store_true', default=False, help='Run yamllint over the specified recipe; useful for finding errors in the recipe') parser.add_argument('--debug', action='store_true', default=False, help='Enable debug mode. If an exception is encountered, drop into an ipdb debugger session')