feat: auto infer formats
This commit is contained in:
@@ -26,7 +26,7 @@ from yamllint import APP_DESCRIPTION, APP_NAME, APP_VERSION
|
|||||||
from yamllint import linter
|
from yamllint import linter
|
||||||
from yamllint.config import YamlLintConfig, YamlLintConfigError
|
from yamllint.config import YamlLintConfig, YamlLintConfigError
|
||||||
from yamllint.linter import PROBLEM_LEVELS
|
from yamllint.linter import PROBLEM_LEVELS
|
||||||
from yamllint.format import show_all_problems
|
from yamllint.format import show_all_problems, Formater
|
||||||
|
|
||||||
|
|
||||||
def find_files_recursively(items, conf):
|
def find_files_recursively(items, conf):
|
||||||
@@ -58,8 +58,7 @@ def run(argv=None):
|
|||||||
action='store',
|
action='store',
|
||||||
help='custom configuration (as YAML source)')
|
help='custom configuration (as YAML source)')
|
||||||
parser.add_argument('-f', '--format',
|
parser.add_argument('-f', '--format',
|
||||||
choices=('parsable', 'standard', 'colored', 'github',
|
choices=[*Formater.get_formaters_names(), 'auto'],
|
||||||
'json', 'junitxml', 'codeclimate', 'auto'),
|
|
||||||
default='auto', help='format for parsing output')
|
default='auto', help='format for parsing output')
|
||||||
parser.add_argument('-s', '--strict',
|
parser.add_argument('-s', '--strict',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ class Formater(object):
|
|||||||
# the formater name
|
# the formater name
|
||||||
name = ''
|
name = ''
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_formaters_names(cls):
|
||||||
|
"""Return all formaters names."""
|
||||||
|
return [f.name for f in cls.__subclasses__()]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_formater(cls, name, no_warn):
|
def get_formater(cls, name, no_warn):
|
||||||
"""Return a formater instance."""
|
"""Return a formater instance."""
|
||||||
|
|||||||
Reference in New Issue
Block a user