cli: Add --list-files command line option

This option lists the files to lint by yamllint, taking into account `ignore`
and `yaml-files` configuration options.
This commit is contained in:
Peter Leitzen
2023-01-10 18:48:38 +01:00
committed by GitHub
parent 2a904f8fc1
commit fa0bb03f9a
3 changed files with 55 additions and 0 deletions

View File

@@ -157,6 +157,8 @@ def run(argv=None):
config_group.add_argument('-d', '--config-data', dest='config_data',
action='store',
help='custom configuration (as YAML source)')
parser.add_argument('--list-files', action='store_true', dest='list_files',
help='list files to lint and exit')
parser.add_argument('-f', '--format',
choices=('parsable', 'standard', 'colored', 'github',
'auto'),
@@ -207,6 +209,12 @@ def run(argv=None):
if conf.locale is not None:
locale.setlocale(locale.LC_ALL, conf.locale)
if args.list_files:
for file in find_files_recursively(args.files, conf):
if not conf.is_file_ignored(file):
print(file)
sys.exit(0)
max_level = 0
for file in find_files_recursively(args.files, conf):