2023-08-27 20:49:23 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import json
|
|
|
|
|
|
|
|
tool_path = sys.argv[1]
|
|
|
|
|
|
|
|
tools = {
|
|
|
|
"linters": {},
|
|
|
|
"formatters": {},
|
|
|
|
}
|
|
|
|
|
2023-08-28 23:44:42 +02:00
|
|
|
identity_langs = [
|
|
|
|
"bash",
|
2023-10-09 13:22:28 +02:00
|
|
|
"blade",
|
2023-08-28 23:44:42 +02:00
|
|
|
"c",
|
|
|
|
"clojure",
|
|
|
|
"cmake",
|
|
|
|
"crystal",
|
|
|
|
"csh",
|
|
|
|
"css",
|
|
|
|
"d",
|
|
|
|
"dart",
|
|
|
|
"fish",
|
|
|
|
"gitcommit",
|
|
|
|
"go",
|
|
|
|
"haskell",
|
|
|
|
"html",
|
|
|
|
"java",
|
|
|
|
"javascript",
|
|
|
|
"json",
|
2023-10-09 13:22:28 +02:00
|
|
|
"jsonc",
|
2023-08-28 23:44:42 +02:00
|
|
|
"ksh",
|
|
|
|
"less",
|
|
|
|
"lua",
|
2023-10-09 13:22:28 +02:00
|
|
|
"make",
|
2023-08-28 23:44:42 +02:00
|
|
|
"markdown",
|
|
|
|
"nix",
|
|
|
|
"pawn",
|
|
|
|
"php",
|
2023-10-09 13:22:28 +02:00
|
|
|
"proto",
|
2023-08-28 23:44:42 +02:00
|
|
|
"python",
|
|
|
|
"roslyn",
|
|
|
|
"ruby",
|
|
|
|
"rust",
|
|
|
|
"sass",
|
2023-10-09 13:22:28 +02:00
|
|
|
"scala",
|
2023-08-28 23:44:42 +02:00
|
|
|
"scss",
|
|
|
|
"sh",
|
|
|
|
"slim",
|
|
|
|
"sml",
|
|
|
|
"solidity",
|
2023-10-09 13:22:28 +02:00
|
|
|
"tex",
|
2023-08-28 23:44:42 +02:00
|
|
|
"toml",
|
|
|
|
"typescript",
|
|
|
|
"vala",
|
|
|
|
"vim",
|
|
|
|
"yaml",
|
|
|
|
"zsh",
|
|
|
|
"misc",
|
|
|
|
]
|
|
|
|
|
|
|
|
lang_map = {
|
|
|
|
"c#": "cs",
|
|
|
|
"c++": "cpp",
|
|
|
|
"docker": "dockerfile",
|
|
|
|
"objective-c": "objc",
|
|
|
|
"objective-c++": "objcpp",
|
|
|
|
"terraform": "tf",
|
|
|
|
}
|
|
|
|
|
|
|
|
for lang in identity_langs:
|
|
|
|
lang_map[lang] = lang
|
|
|
|
|
2023-08-27 20:49:23 +02:00
|
|
|
for kind in ["linters", "formatters"]:
|
|
|
|
for file in os.listdir(tool_path + "/" + kind):
|
|
|
|
tool_name = file.removesuffix(".lua")
|
|
|
|
languages = []
|
|
|
|
with open(tool_path + "/" + kind + "/" + file) as f:
|
|
|
|
for line in f.readlines():
|
|
|
|
if line.startswith("-- languages:"):
|
2023-08-28 18:27:03 +02:00
|
|
|
languages = [
|
2023-08-28 23:44:42 +02:00
|
|
|
lang_map[l.strip()]
|
|
|
|
for l in line.split(":")[1].strip().split(",")
|
2023-08-28 18:27:03 +02:00
|
|
|
]
|
2023-08-27 20:49:23 +02:00
|
|
|
break
|
|
|
|
tools[kind][tool_name] = languages
|
|
|
|
|
2023-08-28 13:48:46 +02:00
|
|
|
print(json.dumps(tools, indent=4, sort_keys=True))
|