File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import re
2+ import sys
3+ import json
4+ from typing import Tuple , List
5+
6+ def run (cmd : str , cwd : str ) -> dict :
7+ # For simplicity, we'll just analyze the passed command
8+ # In a real scenario, you'd use subprocess to actually run the command
9+ problems = find_all (cmd )
10+ return {
11+ "ok" : len (problems ) == 0 ,
12+ "message" : f"Analyzed command: { cmd } " ,
13+ "problems" : formatting (problems , "error" )
14+ }
15+
16+ def find_all (output : str ) -> List [Tuple [str , str , str ]]:
17+ return re .findall (r"File \"./([^\"]+)\", line (\d+)\n.*\n.*\n(.*)" , output )
18+
19+ def formatting (problems : List [Tuple [str , str , str ]], kind : str ) -> List [dict ]:
20+ result = []
21+ for (file , row , msg ) in problems :
22+ result .append ({
23+ "file" : file ,
24+ "type" : kind ,
25+ "row" : int (row ) - 1 ,
26+ "col" : 0 ,
27+ "text" : msg
28+ })
29+ return result
30+
31+ if __name__ == "__main__" :
32+ cmd = sys .argv [1 ] if len (sys .argv ) > 1 else ""
33+ result = run (cmd , "." )
34+ print (json .dumps (result ))
You can’t perform that action at this time.
0 commit comments