11script "Linter"
22
3+ local sErrorsList
4+
35on startup
46 try
5- read from stdin until empty
6- put it into theScript
7+ local tScope
8+ repeat for each element theArgument in the commandArguments
9+ if theArgument begins with "-scope" then
10+ split theArgument with "="
11+ put theArgument [2 ] into tScope
12+ end if
13+ end repeat
714
8- local isScriptOnly = false
9- if word 1 of theScript is "script" then
10- put true into isScriptOnly
11- end if
15+ read from stdin until empty
16+ put it into tScript
1217
1318 put the filename of me into theFilename
1419 set the itemDelimiter to slash
1520 put "scriptErrors.txt" into item - 1 of theFilename
16- put url ("file:" & theFilename ) into theErrorsList
21+ put url ("file:" & theFilename ) into sErrorsList
22+ split sErrorsList with return
1723
1824 create script only stack "TestScript"
1925
20- if isScriptOnly then
21- delete line 1 of theScript
22- end if
23-
24- set the script of stack "TestScript" to theScript
26+ if tScope is empty or tScope is ".source.livecodescript" then
27+ local tLineOffset = 0
2528
26- put the result into theErrors
27- set the itemDelimiter to comma
29+ -- check for script only
30+ if word 1 of tScript is "script" then
31+ put 1 into tLineOffset
32+ end if
2833
29- repeat for each line theError in theErrors
30- if theError is not empty then
31- if isScriptOnly then
32- add 1 to item 2 of theError
33- end if
34- write item 2 of theError , line (item 1 of theError ) of theErrorsList & linefeed to stdout
34+ if tLineOffset is 1 then
35+ delete line 1 of tScript
3536 end if
36- end repeat
37+
38+ LintScript tScript , tLineOffset
39+ else if tScope is ".source.iRev" then
40+
41+ end if
3742
3843 write linefeed to stdout
3944 catch e
@@ -42,3 +47,16 @@ on startup
4247
4348 quit
4449end startup
50+
51+ command LintScript pScript, pLineOffset
52+ set the script of stack "TestScript" to pScript
53+
54+ put the result into theErrors
55+ set the itemDelimiter to comma
56+
57+ repeat for each line theError in theErrors
58+ if theError is not empty then
59+ write item 2 of theError + pLineOffset , item 3 of theError , sErrorsList [item 1 of theError ] & linefeed to stdout
60+ end if
61+ end repeat
62+ end LintScript
0 commit comments